diff --git a/programs/taskmgr/graphctl.c b/programs/taskmgr/graphctl.c index adfde9003a4..40acc612285 100644 --- a/programs/taskmgr/graphctl.c +++ b/programs/taskmgr/graphctl.c @@ -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(); } diff --git a/programs/winemine/main.c b/programs/winemine/main.c index 746645599b6..65783b5d38e 100644 --- a/programs/winemine/main.c +++ b/programs/winemine/main.c @@ -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 ); } diff --git a/programs/winhelp/hlp2sgml.c b/programs/winhelp/hlp2sgml.c index c0660fc723a..8063148fcb8 100644 --- a/programs/winhelp/hlp2sgml.c +++ b/programs/winhelp/hlp2sgml.c @@ -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; +} diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c index 4810085282d..24d5d4e230c 100644 --- a/programs/winhelp/hlpfile.c +++ b/programs/winhelp/hlpfile.c @@ -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;