[dlls/winecfg/drive.c] Strncpy elimination.

Peter Berg Larsen pebl at math.ku.dk
Sun Mar 27 12:22:16 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: programs/winecfg/drive.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/drive.c,v
retrieving revision 1.24
diff -u -r1.24 drive.c
--- programs/winecfg/drive.c	14 Mar 2005 10:05:12 -0000	1.24
+++ programs/winecfg/drive.c	26 Mar 2005 09:41:55 -0000
@@ -230,7 +230,7 @@
         WINE_TRACE("serial: '0x%lX'\n", serial);

         /* build rootpath for GetDriveType() */
-        strncpy(rootpath, devices, sizeof(rootpath));
+        lstrcpynA(rootpath, devices, sizeof(rootpath));
         pathlen = strlen(rootpath);

         /* ensure that we have a backslash on the root path */
@@ -240,8 +240,8 @@
             rootpath[pathlen + 1] = 0;
         }

-        strncpy(simplepath, devices, 2); /* QueryDosDevice() requires no trailing backslash */
-        simplepath[2] = 0;
+	/* QueryDosDevice() requires no trailing backslash */
+        lstrcpynA(simplepath, devices, 3);
         QueryDosDevice(simplepath, targetpath, sizeof(targetpath));

         /* targetpath may have forward slashes rather than backslashes, so correct */





More information about the wine-patches mailing list