ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ACADr2015 _tcsncpy problem ?

1 REPLY 1
Reply
Message 1 of 2
XXL1966
359 Views, 1 Reply

ACADr2015 _tcsncpy problem ?

hi,

 

'im having trouble with this code

this code reads dongle information

 

 

        retcode = SDX_Read(handle, 2, buffer);
        if (retcode < 0)
        {
            ads_printf(_T("Error READING dongle: %08x\n"), retcode);
            acedRetNil();
        }
        for(int i = 0; i < 512; i++)
        {
            block2[i] = (TCHAR) buffer[i];
        }
        block2[8]=_T('\0');

        TCHAR Dd[2];
        TCHAR Dm[2];
        TCHAR Dj[2];
        _tcsncpy(Dj,block2+0,2);
    //    Dj[2]=_T('\0');
        _tcsncpy(Dm,block2+3,2);
    //    Dm[2]=_T('\0');
        _tcsncpy(Dd,block2+6,2);
    //    Dd[2]=_T('\0');

 

acad 2015 crashed on the commented lines, works fine in any other acads

 

block2 contains "12.07.20" a date which is correct.

 

what am i'm missing or doing wrong ?

 

ty !

1 REPLY 1
Message 2 of 2
owenwengerd
in reply to: XXL1966

The commented lines are each writing past the end of a 2-element array, a classical buffer overrun error.

--
Owen Wengerd
ManuSoft

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost