This project has moved. For the latest updates, please go here.
1

Closed

Bug in MyStrCpy

description

It contains the line strncpy_s(szDest, nMaxDestSize, szSrc, nMaxDestSize); which causes an invalid parameter exception, because the fourth parameter must always be strictly less than the second.

According to http://msdn.microsoft.com/en-us/library/5dae5d43%28v=vs.80%29.aspx
strncpy_s(szDest, nMaxDestSize, szSrc, nMaxDestSize - 1); should be used.

Alternatively, the strncpy_s function could be called with _TRUNCATE, so the whole function can be simplifed to:
static void MyStrCpy(char* szDest, size_t nMaxDestSize, const char* szSrc)
{
    if (nMaxDestSize <= 0) {
        return;
    }
    strncpy_s(szDest, nMaxDestSize, szSrc, _TRUNCATE);
}  // MyStrCpy
Closed Sep 14, 2014 at 7:14 PM by jkalmbach
Resolved in main-trunk

comments

jkalmbach wrote Sep 14, 2014 at 7:13 PM

Solved in main trunk. Thanks for reporting!