Janitorial: Get rid of strncpy/strncpyW.
diff --git a/dlls/msacm/format.c b/dlls/msacm/format.c index fa20995..c1f150f 100644 --- a/dlls/msacm/format.c +++ b/dlls/msacm/format.c
@@ -72,7 +72,7 @@ if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) { ACMFORMATDETAILSA afd; - unsigned int i, idx; + unsigned int i, len; MMRESULT mmr; char buffer[ACMFORMATDETAILS_FORMAT_CHARS+16]; @@ -88,10 +88,9 @@ afd.dwFormatIndex = i; mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX); if (mmr == MMSYSERR_NOERROR) { - strncpy(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS); - for (idx = strlen(buffer); - idx < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; idx++) - buffer[idx] = ' '; + lstrcpynA(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1); + len = strlen(buffer); + memset(buffer+len, ' ', ACMFORMATTAGDETAILS_FORMATTAG_CHARS - len); wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS, "%d Ko/s", (afd.pwfx->nAvgBytesPerSec + 512) / 1024);
diff --git a/dlls/psapi/psapi_main.c b/dlls/psapi/psapi_main.c index bd1c73b..09573a1 100644 --- a/dlls/psapi/psapi_main.c +++ b/dlls/psapi/psapi_main.c
@@ -338,6 +338,7 @@ { WCHAR tmp[MAX_PATH]; WCHAR* ptr; + int ptrlen; if(!lpBaseName || !nSize) { SetLastError(ERROR_INVALID_PARAMETER); @@ -349,8 +350,9 @@ return 0; TRACE("%s\n", debugstr_w(tmp)); if ((ptr = strrchrW(tmp, '\\')) != NULL) ptr++; else ptr = tmp; - strncpyW(lpBaseName, ptr, nSize); - return min(strlenW(ptr), nSize); + ptrlen = strlenW(ptr); + memcpy(lpBaseName, ptr, min(ptrlen+1,nSize) * sizeof(WCHAR)); + return min(ptrlen, nSize); } /***********************************************************************
diff --git a/dlls/user/text.c b/dlls/user/text.c index 4723b10..fde3097 100644 --- a/dlls/user/text.c +++ b/dlls/user/text.c
@@ -163,7 +163,7 @@ /* Now this should take only a couple iterations at most. */ for ( ; ; ) { - strncpyW (str + *len_str, ELLIPSISW, len_ellipsis); + memcpy(str + *len_str, ELLIPSISW, len_ellipsis*sizeof(WCHAR)); if (!GetTextExtentExPointW (hdc, str, *len_str + len_ellipsis, width, NULL, NULL, size)) break; @@ -178,7 +178,7 @@ if (modstr) { - strncpyW (modstr, str, *len_str); + memcpy (modstr, str, *len_str * sizeof(WCHAR)); *(str+*len_str) = '\0'; } } @@ -253,7 +253,7 @@ /* overlap-safe movement to the right */ memmove (lastSlash+len_ellipsis, lastSlash, len_trailing * sizeof(WCHAR)); - strncpyW (lastSlash, ELLIPSISW, len_ellipsis); + memcpy (lastSlash, ELLIPSISW, len_ellipsis*sizeof(WCHAR)); len_trailing += len_ellipsis; /* From this point on lastSlash actually points to the ellipsis in front * of the last slash and len_trailing includes the ellipsis
diff --git a/dlls/wininet/netconnection.c b/dlls/wininet/netconnection.c index 9170e64..4ab94b4 100644 --- a/dlls/wininet/netconnection.c +++ b/dlls/wininet/netconnection.c
@@ -354,16 +354,18 @@ } else if (flags & MSG_PEEK && peek_msg) { - if (len < strlen(peek_msg)) + size_t peek_msg_len = strlen(peek_msg); + if (len < peek_msg_len) FIXME("buffer isn't big enough. Do the expect us to wrap?\n"); - strncpy(buf, peek_msg, len); - *recvd = (strlen(peek_msg) <= len ? strlen(peek_msg) : len); + memcpy(buf, peek_msg, min(len,peek_msg_len+1)); + *recvd = min(len, peek_msg_len); return TRUE; } else if (peek_msg) { - strncpy(buf, peek_msg, len); - peek_msg += *recvd = min(len, strlen(peek_msg)); + size_t peek_msg_len = strlen(peek_msg); + memcpy(buf, peek_msg, min(len,peek_msg_len+1)); + peek_msg += *recvd = min(len, peek_msg_len); if (*peek_msg == '\0' || *(peek_msg - 1) == '\0') { HeapFree(GetProcessHeap(), 0, peek_msg_mem); @@ -383,7 +385,7 @@ } else { - strncpy(peek_msg, buf, *recvd); + memcpy(peek_msg, buf, *recvd); peek_msg[*recvd] = '\0'; } }