Removed a few more strncpy calls.

This commit is contained in:
Alexandre Julliard 2005-04-26 14:35:53 +00:00
parent d70a253f40
commit e197332fa7
4 changed files with 26 additions and 8 deletions

View File

@ -153,14 +153,14 @@ void GraphCtrl_SetRange(TGraphCtrl* this, double dLower, double dUpper, int nDec
#if 0
void TGraphCtrl::SetXUnits(const char* string)
{
strncpy(m_strXUnitsString, string, sizeof(m_strXUnitsString) - 1);
lstrcpynA(m_strXUnitsString, string, sizeof(m_strXUnitsString));
/* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl();
}
void TGraphCtrl::SetYUnits(const char* string)
{
strncpy(m_strYUnitsString, string, sizeof(m_strYUnitsString) - 1);
lstrcpynA(m_strYUnitsString, string, sizeof(m_strYUnitsString));
/* clear out the existing garbage, re-start with a clean plot */
InvalidateCtrl();
}

View File

@ -336,7 +336,7 @@ void LoadBoard( BOARD *p_board )
if( RegQueryValueEx( hkey, key_name, NULL, (LPDWORD) &type,
(LPBYTE) data,
(LPDWORD) &size ) == ERROR_SUCCESS )
strncpy( p_board->best_name[i], data, sizeof( data ) );
lstrcpynA( p_board->best_name[i], data, sizeof(p_board->best_name[i]) );
else
LoadString( p_board->hInst, IDS_NOBODY, p_board->best_name[i], 16 );
}

View File

@ -392,3 +392,18 @@ LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
strcpy( dst, src );
return dst;
}
LPSTR WINAPI lstrcpynA( LPSTR dst, LPCSTR src, INT n )
{
LPSTR d = dst;
LPCSTR s = src;
UINT count = n;
while ((count > 1) && *s)
{
count--;
*d++ = *s++;
}
if (count) *d = 0;
return dst;
}

View File

@ -1207,8 +1207,8 @@ static BOOL HLPFILE_ReadFont(HLPFILE* hlpfile)
if (idx < face_num)
{
strncpy(hlpfile->fonts[i].LogFont.lfFaceName, ref + face_offset + idx * len, min(len, LF_FACESIZE - 1));
hlpfile->fonts[i].LogFont.lfFaceName[min(len, LF_FACESIZE - 1) + 1] = '\0';
memcpy(hlpfile->fonts[i].LogFont.lfFaceName, ref + face_offset + idx * len, min(len, LF_FACESIZE - 1));
hlpfile->fonts[i].LogFont.lfFaceName[min(len, LF_FACESIZE - 1)] = '\0';
}
else
{
@ -1415,9 +1415,12 @@ static BOOL HLPFILE_SystemCommands(HLPFILE* hlpfile)
unsigned flags = GET_USHORT(ptr, 4);
HLPFILE_WINDOWINFO* wi = &hlpfile->windows[hlpfile->numWindows - 1];
if (flags & 0x0001) strcpy(wi->type, ptr + 6); else wi->type[0] = '\0';
if (flags & 0x0002) strcpy(wi->name, ptr + 16); else wi->name[0] = '\0';
if (flags & 0x0004) strcpy(wi->caption, ptr + 25); else strncpy(wi->caption, hlpfile->lpszTitle, sizeof(wi->caption));
if (flags & 0x0001) strcpy(wi->type, ptr + 6);
else wi->type[0] = '\0';
if (flags & 0x0002) strcpy(wi->name, ptr + 16);
else wi->name[0] = '\0';
if (flags & 0x0004) strcpy(wi->caption, ptr + 25);
else lstrcpynA(wi->caption, hlpfile->lpszTitle, sizeof(wi->caption));
wi->origin.x = (flags & 0x0008) ? GET_USHORT(ptr, 76) : CW_USEDEFAULT;
wi->origin.y = (flags & 0x0010) ? GET_USHORT(ptr, 78) : CW_USEDEFAULT;
wi->size.cx = (flags & 0x0020) ? GET_USHORT(ptr, 80) : CW_USEDEFAULT;