[dlls/wininet/*] Strncpy elimination.
Peter Berg Larsen
pebl at math.ku.dk
Sun Mar 27 12:18:57 CST 2005
I have been checking the usage of strncpy, replacing where apropriate with
a memcpy or lstrcpyn[AW]. The first raw diff was 100kb, so there is bound
to be one or two slips. These are the first batch which I found to be
obvious, correct, and didnt need a special comment. Note with correct I
mean if there was a \0 bug before then it still there.
Changelog:
Janitorial Task: Check the usage of strncpy/strncpyW.
Index: dlls/wininet/cookie.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/cookie.c,v
retrieving revision 1.13
diff -u -r1.13 cookie.c
--- dlls/wininet/cookie.c 26 Jan 2005 21:09:04 -0000 1.13
+++ dlls/wininet/cookie.c 26 Mar 2005 09:41:30 -0000
@@ -410,6 +410,7 @@
WCHAR *ourCookieName, *ourCookieData;
int ourCookieNameSize;
BOOL ret;
+
if (!(ourCookieData = strchrW(lpCookieData, '=')))
{
TRACE("something terribly wrong with cookie data %s\n",
@@ -420,7 +421,7 @@
ourCookieData += 1;
ourCookieName = HeapAlloc(GetProcessHeap(), 0,
(ourCookieNameSize + 1)*sizeof(WCHAR));
- strncpyW(ourCookieName, ourCookieData, ourCookieNameSize);
+ memcpy(ourCookieName, ourCookieData, ourCookieNameSize * sizeof(WCHAR));
ourCookieName[ourCookieNameSize] = '\0';
TRACE("setting (hacked) cookie of %s, %s\n",
debugstr_w(ourCookieName), debugstr_w(ourCookieData));
Index: dlls/wininet/ftp.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/ftp.c,v
retrieving revision 1.52
diff -u -r1.52 ftp.c
--- dlls/wininet/ftp.c 1 Feb 2005 18:50:54 -0000 1.52
+++ dlls/wininet/ftp.c 26 Mar 2005 09:41:35 -0000
@@ -2777,7 +2777,7 @@
lpFindFileData->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
if (lpafp->lpszName)
- strncpyW(lpFindFileData->cFileName, lpafp->lpszName, MAX_PATH);
+ lstrcpynW(lpFindFileData->cFileName, lpafp->lpszName, MAX_PATH);
bSuccess = TRUE;
}
Index: dlls/wininet/utility.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/utility.c,v
retrieving revision 1.25
diff -u -r1.25 utility.c
--- dlls/wininet/utility.c 4 Jan 2005 20:38:53 -0000 1.25
+++ dlls/wininet/utility.c 26 Mar 2005 09:41:44 -0000
@@ -53,6 +53,7 @@
if(!asctime || !timelen)
return 0;
+ /* The atoiWs below relie on that tmpChar is \0 padded? */
strncpyW(tmpChar, asctime, TIME_STRING_LEN);
/* Assert that the string is the expected length */
More information about the wine-patches
mailing list