Further strncpy eliminations

Peter Berg Larsen pebl at math.ku.dk
Fri Apr 15 15:53:32 CDT 2005


This patch elliminates some strncpys in a trivial way a to memcpy or
lstrcpyn. There is way to many to send individually. Do look it through as
I might have missed something. The more difficult eliminations follows.


Files touched:

dlls/comctl32/tooltips.c
dlls/commdlg/filedlg.c
dlls/devenum/parsedisplayname.c
dlls/dmband/band.c
dlls/dmcompos/chordmap.c
dlls/dmime/audiopath.c
dlls/dmime/graph.c
dlls/dmime/segment.c
dlls/dmloader/loaderstream.c
dlls/dmscript/script.c
dlls/dmstyle/style.c
dlls/gdi/font.c
dlls/gdi/freetype.c
dlls/itss/chm_lib.c
dlls/msi/cond.y
dlls/msvcrt/locale.c
dlls/msvideo/mciwnd.c
dlls/msvideo/msvideo16.c
dlls/ntdll/file.c
dlls/ntdll/time.c
dlls/oledlg/insobjdlg.c
dlls/quartz/filtermapper.c
dlls/shell32/debughlp.c
dlls/shell32/shelllink.c
dlls/shell32/shellpath.c
dlls/shell32/shlexec.c
dlls/shell32/systray.c
dlls/user/edit.c
dlls/winedos/int21.c
dlls/wininet/dialogs.c
dlls/wininet/internet.c
dlls/wininet/utility.c
dlls/winmm/wineoss/audio.c
programs/winecfg/drivedetect.c
tools/sfnt2fnt.c


Changelog:
     Replace strncpy with memcpy or lstrcpyn.


Index: dlls/comctl32/tooltips.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/tooltips.c,v
retrieving revision 1.77
diff -u -r1.77 tooltips.c
--- dlls/comctl32/tooltips.c	23 Mar 2005 10:24:20 -0000	1.77
+++ dlls/comctl32/tooltips.c	15 Apr 2005 20:13:45 -0000
@@ -387,7 +387,7 @@
     else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) {
         INT max_len = (ttnmdi.lpszText == &ttnmdi.szText[0]) ?
                 sizeof(ttnmdi.szText)/sizeof(ttnmdi.szText[0]) : INFOTIPSIZE-1;
-        strncpyW(infoPtr->szTipText, ttnmdi.lpszText, max_len);
+        lstrcpynW(infoPtr->szTipText, ttnmdi.lpszText, max_len);
         if (ttnmdi.uFlags & TTF_DI_SETITEM) {
             INT len = max(strlenW(ttnmdi.lpszText), max_len);
             toolPtr->hinst = 0;
Index: dlls/commdlg/filedlg.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg.c,v
retrieving revision 1.101
diff -u -r1.101 filedlg.c
--- dlls/commdlg/filedlg.c	28 Mar 2005 14:58:53 -0000	1.101
+++ dlls/commdlg/filedlg.c	15 Apr 2005 20:13:48 -0000
@@ -2065,7 +2065,7 @@
             if(fodInfos->unicode)
             {
               LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
-	      strncpyW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
+	      lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
             }
             else
             {
Index: dlls/devenum/parsedisplayname.c
===================================================================
RCS file: /home/wine/wine/dlls/devenum/parsedisplayname.c,v
retrieving revision 1.8
diff -u -r1.8 parsedisplayname.c
--- dlls/devenum/parsedisplayname.c	7 Dec 2004 14:37:11 -0000	1.8
+++ dlls/devenum/parsedisplayname.c	15 Apr 2005 20:13:51 -0000
@@ -94,6 +94,7 @@
     MediaCatMoniker * pMoniker = NULL;
     CLSID clsidDevice;
     HRESULT res = S_OK;
+    int classlen;

     TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut);

@@ -107,12 +108,13 @@
     /* size = pszBetween - pszDisplayName - 1 (for '\\' after CLSID)
      * + 1 (for NULL character)
      */
-    pszClass = CoTaskMemAlloc((int)(pszBetween - pszDisplayName) * sizeof(WCHAR));
+    classlen = (int)(pszBetween - pszDisplayName - 1);
+    pszClass = CoTaskMemAlloc((classlen + 1) * sizeof(WCHAR));
     if (!pszClass)
         return E_OUTOFMEMORY;

-    strncpyW(pszClass, pszDisplayName, (int)(pszBetween - pszDisplayName) - 1);
-    pszClass[(int)(pszBetween - pszDisplayName) - 1] = 0;
+    memcpy(pszClass, pszDisplayName, classlen * sizeof(WCHAR));
+    pszClass[classlen] = 0;

     TRACE("Device CLSID: %s\n", debugstr_w(pszClass));

Index: dlls/dmband/band.c
===================================================================
RCS file: /home/wine/wine/dlls/dmband/band.c,v
retrieving revision 1.17
diff -u -r1.17 band.c
--- dlls/dmband/band.c	28 Mar 2005 14:58:53 -0000	1.17
+++ dlls/dmband/band.c	15 Apr 2005 20:13:52 -0000
@@ -163,11 +163,11 @@
 	if (pDesc->dwValidData & DMUS_OBJ_CLASS)
 		memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
 	if (pDesc->dwValidData & DMUS_OBJ_NAME)
-		strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
+		lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
 	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
-		strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
+		lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
 	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-		strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
+		lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
 	if (pDesc->dwValidData & DMUS_OBJ_VERSION)
 		memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
 	if (pDesc->dwValidData & DMUS_OBJ_DATE)
Index: dlls/dmcompos/chordmap.c
===================================================================
RCS file: /home/wine/wine/dlls/dmcompos/chordmap.c,v
retrieving revision 1.12
diff -u -r1.12 chordmap.c
--- dlls/dmcompos/chordmap.c	28 Mar 2005 14:58:53 -0000	1.12
+++ dlls/dmcompos/chordmap.c	15 Apr 2005 20:13:53 -0000
@@ -147,11 +147,11 @@
 	if (pDesc->dwValidData & DMUS_OBJ_CLASS)
 		memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
 	if (pDesc->dwValidData & DMUS_OBJ_NAME)
-		strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
+		lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
 	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
-		strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
+		lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
 	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-		strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
+		lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
 	if (pDesc->dwValidData & DMUS_OBJ_VERSION)
 		memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
 	if (pDesc->dwValidData & DMUS_OBJ_DATE)
Index: dlls/dmime/audiopath.c
===================================================================
RCS file: /home/wine/wine/dlls/dmime/audiopath.c,v
retrieving revision 1.16
diff -u -r1.16 audiopath.c
--- dlls/dmime/audiopath.c	28 Mar 2005 14:58:52 -0000	1.16
+++ dlls/dmime/audiopath.c	15 Apr 2005 20:13:53 -0000
@@ -262,11 +262,11 @@
 	if (pDesc->dwValidData & DMUS_OBJ_CLASS)
 		memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
 	if (pDesc->dwValidData & DMUS_OBJ_NAME)
-		strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
+		lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
 	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
-		strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
+		lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
 	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-		strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
+		lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
 	if (pDesc->dwValidData & DMUS_OBJ_VERSION)
 		memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
 	if (pDesc->dwValidData & DMUS_OBJ_DATE)
Index: dlls/dmime/graph.c
===================================================================
RCS file: /home/wine/wine/dlls/dmime/graph.c,v
retrieving revision 1.13
diff -u -r1.13 graph.c
--- dlls/dmime/graph.c	28 Mar 2005 14:58:52 -0000	1.13
+++ dlls/dmime/graph.c	15 Apr 2005 20:13:54 -0000
@@ -228,11 +228,11 @@
 	if (pDesc->dwValidData & DMUS_OBJ_CLASS)
 		memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
 	if (pDesc->dwValidData & DMUS_OBJ_NAME)
-		strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
+		lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
 	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
-		strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
+		lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
 	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-		strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
+		lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
 	if (pDesc->dwValidData & DMUS_OBJ_VERSION)
 		memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
 	if (pDesc->dwValidData & DMUS_OBJ_DATE)
Index: dlls/dmime/segment.c
===================================================================
RCS file: /home/wine/wine/dlls/dmime/segment.c,v
retrieving revision 1.23
diff -u -r1.23 segment.c
--- dlls/dmime/segment.c	28 Mar 2005 14:58:52 -0000	1.23
+++ dlls/dmime/segment.c	15 Apr 2005 20:13:55 -0000
@@ -548,11 +548,11 @@
 	if (pDesc->dwValidData & DMUS_OBJ_CLASS)
 		memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
 	if (pDesc->dwValidData & DMUS_OBJ_NAME)
-		strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
+		lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
 	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
-		strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
+		lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
 	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-		strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
+		lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
 	if (pDesc->dwValidData & DMUS_OBJ_VERSION)
 		memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
 	if (pDesc->dwValidData & DMUS_OBJ_DATE)
Index: dlls/dmloader/loaderstream.c
===================================================================
RCS file: /home/wine/wine/dlls/dmloader/loaderstream.c,v
retrieving revision 1.13
diff -u -r1.13 loaderstream.c
--- dlls/dmloader/loaderstream.c	22 Dec 2004 15:13:20 -0000	1.13
+++ dlls/dmloader/loaderstream.c	15 Apr 2005 20:13:57 -0000
@@ -67,7 +67,7 @@
     }
     /* create IDirectMusicGetLoader */
     This->pLoader = (LPDIRECTMUSICLOADER8)pLoader;
-    strncpyW (This->wzFileName, wzFile, MAX_PATH);
+    lstrcpynW (This->wzFileName, wzFile, MAX_PATH);
     TRACE(": succeeded\n");
     return S_OK;
 }
Index: dlls/dmscript/script.c
===================================================================
RCS file: /home/wine/wine/dlls/dmscript/script.c,v
retrieving revision 1.19
diff -u -r1.19 script.c
--- dlls/dmscript/script.c	2 Feb 2005 09:31:28 -0000	1.19
+++ dlls/dmscript/script.c	15 Apr 2005 20:13:57 -0000
@@ -226,11 +226,11 @@
   if (pDesc->dwValidData & DMUS_OBJ_CLASS)
     memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
   if (pDesc->dwValidData & DMUS_OBJ_NAME)
-    strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
+    lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
   if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
-    strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
+    lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
   if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-    strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
+    lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
   if (pDesc->dwValidData & DMUS_OBJ_VERSION)
     memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
   if (pDesc->dwValidData & DMUS_OBJ_DATE)
Index: dlls/dmstyle/style.c
===================================================================
RCS file: /home/wine/wine/dlls/dmstyle/style.c,v
retrieving revision 1.14
diff -u -r1.14 style.c
--- dlls/dmstyle/style.c	24 Jan 2005 19:33:23 -0000	1.14
+++ dlls/dmstyle/style.c	15 Apr 2005 20:13:58 -0000
@@ -230,11 +230,11 @@
 	if (pDesc->dwValidData & DMUS_OBJ_CLASS)
 		memcpy (&This->pDesc->guidClass, &pDesc->guidClass, sizeof (pDesc->guidClass));
 	if (pDesc->dwValidData & DMUS_OBJ_NAME)
-		strncpyW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
+		lstrcpynW (This->pDesc->wszName, pDesc->wszName, DMUS_MAX_NAME);
 	if (pDesc->dwValidData & DMUS_OBJ_CATEGORY)
-		strncpyW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
+		lstrcpynW (This->pDesc->wszCategory, pDesc->wszCategory, DMUS_MAX_CATEGORY);
 	if (pDesc->dwValidData & DMUS_OBJ_FILENAME)
-		strncpyW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
+		lstrcpynW (This->pDesc->wszFileName, pDesc->wszFileName, DMUS_MAX_FILENAME);
 	if (pDesc->dwValidData & DMUS_OBJ_VERSION)
 		memcpy (&This->pDesc->vVersion, &pDesc->vVersion, sizeof (pDesc->vVersion));
 	if (pDesc->dwValidData & DMUS_OBJ_DATE)
Index: dlls/gdi/font.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/font.c,v
retrieving revision 1.9
diff -u -r1.9 font.c
--- dlls/gdi/font.c	24 Mar 2005 21:01:38 -0000	1.9
+++ dlls/gdi/font.c	15 Apr 2005 20:14:06 -0000
@@ -2319,7 +2319,7 @@
 		/* Treat the case where no special handling was requested in a fastpath way */
 		/* copy will do if the GCP_REORDER flag is not set */
 		if(lpResults->lpOutString)
-                    strncpyW( lpResults->lpOutString, lpString, nSet );
+                    memcpy( lpResults->lpOutString, lpString, nSet * sizeof(WCHAR));

 		if(lpResults->lpOrder)
 		{
Index: dlls/gdi/freetype.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/freetype.c,v
retrieving revision 1.82
diff -u -r1.82 freetype.c
--- dlls/gdi/freetype.c	25 Feb 2005 13:59:22 -0000	1.82
+++ dlls/gdi/freetype.c	15 Apr 2005 20:14:08 -0000
@@ -2044,13 +2044,13 @@
     if(potm) {
         pntm->ntmTm.ntmSizeEM = potm->otmEMSquare;

-        strncpyW(pelf->elfLogFont.lfFaceName,
+        lstrcpynW(pelf->elfLogFont.lfFaceName,
                  (WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpFamilyName),
                  LF_FACESIZE);
-        strncpyW(pelf->elfFullName,
+        lstrcpynW(pelf->elfFullName,
                  (WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpFaceName),
                  LF_FULLFACESIZE);
-        strncpyW(pelf->elfStyle,
+        lstrcpynW(pelf->elfStyle,
                  (WCHAR*)((char*)potm + (ptrdiff_t)potm->otmpStyleName),
                  LF_FACESIZE);

@@ -2058,8 +2058,8 @@
     } else {
         pntm->ntmTm.ntmSizeEM = pntm->ntmTm.tmHeight - pntm->ntmTm.tmInternalLeading;

-        strncpyW(pelf->elfLogFont.lfFaceName, face->family->FamilyName, LF_FACESIZE);
-        strncpyW(pelf->elfFullName, face->family->FamilyName, LF_FACESIZE);
+        lstrcpynW(pelf->elfLogFont.lfFaceName, face->family->FamilyName, LF_FACESIZE);
+        lstrcpynW(pelf->elfFullName, face->family->FamilyName, LF_FACESIZE);
         pelf->elfStyle[0] = '\0';
     }

Index: dlls/itss/chm_lib.c
===================================================================
RCS file: /home/wine/wine/dlls/itss/chm_lib.c,v
retrieving revision 1.5
diff -u -r1.5 chm_lib.c
--- dlls/itss/chm_lib.c	9 Dec 2004 14:07:59 -0000	1.5
+++ dlls/itss/chm_lib.c	15 Apr 2005 20:14:12 -0000
@@ -1538,7 +1538,7 @@
     curPage = h->index_head;

     /* initialize pathname state */
-    strncpyW(prefixRectified, prefix, CHM_MAX_PATHLEN);
+    lstrcpynW(prefixRectified, prefix, CHM_MAX_PATHLEN);
     prefixLen = strlenW(prefixRectified);
     if (prefixLen != 0)
     {
Index: dlls/msi/cond.y
===================================================================
RCS file: /home/wine/wine/dlls/msi/cond.y,v
retrieving revision 1.16
diff -u -r1.16 cond.y
--- dlls/msi/cond.y	9 Feb 2005 13:26:16 -0000	1.16
+++ dlls/msi/cond.y	15 Apr 2005 20:14:25 -0000
@@ -701,7 +701,7 @@
     ret = HeapAlloc( GetProcessHeap(), 0, (str->len+1) * sizeof (WCHAR) );
     if( ret )
     {
-        strncpyW( ret, str->data, str->len );
+        memcpy( ret, str->data, str->len * sizeof(WCHAR));
         ret[str->len]=0;
     }
     TRACE("Got identifier %s\n",debugstr_w(ret));
Index: dlls/msvcrt/locale.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/locale.c,v
retrieving revision 1.25
diff -u -r1.25 locale.c
--- dlls/msvcrt/locale.c	21 Nov 2004 15:42:03 -0000	1.25
+++ dlls/msvcrt/locale.c	15 Apr 2005 20:14:27 -0000
@@ -372,7 +372,7 @@
   if (next && next != locale)
   {
     haveLang = 1;
-    strncpy(lc.search_language,locale,next-locale);
+    memcpy(lc.search_language,locale,next-locale);
     locale += next-locale+1;
   }

@@ -383,23 +383,23 @@
     if (next == locale)
     {
       locale++;
-      strncpy(lc.search_codepage, locale, MAX_ELEM_LEN);
+      lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN);
     }
     else
     {
       if (haveLang)
       {
         haveCountry = 1;
-        strncpy(lc.search_country,locale,next-locale);
+        memcpy(lc.search_country,locale,next-locale);
         locale += next-locale+1;
       }
       else
       {
         haveLang = 1;
-        strncpy(lc.search_language,locale,next-locale);
+        memcpy(lc.search_language,locale,next-locale);
         locale += next-locale+1;
       }
-      strncpy(lc.search_codepage, locale, MAX_ELEM_LEN);
+      lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN);
     }
   }
   else
@@ -407,12 +407,12 @@
     if (haveLang)
     {
       haveCountry = 1;
-      strncpy(lc.search_country, locale, MAX_ELEM_LEN);
+      lstrcpynA(lc.search_country, locale, MAX_ELEM_LEN);
     }
     else
     {
       haveLang = 1;
-      strncpy(lc.search_language, locale, MAX_ELEM_LEN);
+      lstrcpynA(lc.search_language, locale, MAX_ELEM_LEN);
     }
   }

Index: dlls/msvideo/mciwnd.c
===================================================================
RCS file: /home/wine/wine/dlls/msvideo/mciwnd.c,v
retrieving revision 1.20
diff -u -r1.20 mciwnd.c
--- dlls/msvideo/mciwnd.c	23 Dec 2004 20:20:49 -0000	1.20
+++ dlls/msvideo/mciwnd.c	15 Apr 2005 20:14:28 -0000
@@ -1010,7 +1010,7 @@
         return mwi->lasterror;

     case MCIWNDM_RETURNSTRINGW:
-        strncpyW((LPWSTR)lParam, mwi->return_string, wParam);
+        lstrcpynW((LPWSTR)lParam, mwi->return_string, wParam);
         TRACE("MCIWNDM_RETURNTRINGW %s\n", debugstr_wn((LPWSTR)lParam, wParam));
         return mwi->lasterror;

@@ -1095,7 +1095,7 @@
     case MCIWNDM_GETFILENAMEW:
         TRACE("MCIWNDM_GETFILENAMEW: %s\n", debugstr_w(mwi->lpName));
         if (mwi->lpName)
-            strncpyW((LPWSTR)lParam, mwi->lpName, wParam);
+            lstrcpynW((LPWSTR)lParam, mwi->lpName, wParam);
         return 0;

     case MCIWNDM_GETTIMEFORMATA:
Index: dlls/msvideo/msvideo16.c
===================================================================
RCS file: /home/wine/wine/dlls/msvideo/msvideo16.c,v
retrieving revision 1.13
diff -u -r1.13 msvideo16.c
--- dlls/msvideo/msvideo16.c	28 Mar 2005 14:17:51 -0000	1.13
+++ dlls/msvideo/msvideo16.c	15 Apr 2005 20:14:29 -0000
@@ -764,7 +764,7 @@
 {
     DWORD	verhandle;
     DWORD	infosize;
-    UINT	subblocklen;
+    UINT	copylen,subblocklen;
     char	*s, buf[2048], fn[260];
     LPBYTE	infobuf;
     LPVOID	subblock;
@@ -834,7 +834,7 @@
     else
     {
         TRACE("GetFileVersionInfoA failed for %s.\n", fn);
-        strncpy(buf2, fn, buf2len); /* msvideo.dll appears to copy fn*/
+        lstrcpynA(buf2, fn, buf2len); /* msvideo.dll appears to copy fn*/
     }
     /* FIXME: language problem? */
     if (VerQueryValueA(	infobuf,
@@ -844,12 +844,14 @@
             ))
     {
         TRACE("VQA returned %s\n", (LPCSTR)subblock);
-        strncpy(buf1, subblock, buf1len);
+        copylen = min(subblocklen,buf1len-1);
+        memcpy(buf1, subblock, copylen);
+        buf1[copylen] = '\0';
     }
     else
     {
         TRACE("VQA did not return on query \\StringFileInfo\\040904E4\\FileDescription?\n");
-        strncpy(buf1, fn, buf1len); /* msvideo.dll appears to copy fn*/
+        lstrcpynA(buf1, fn, buf1len); /* msvideo.dll appears to copy fn*/
     }
     HeapFree(GetProcessHeap(), 0, infobuf);
     return 0;
Index: dlls/ntdll/file.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/file.c,v
retrieving revision 1.81
diff -u -r1.81 file.c
--- dlls/ntdll/file.c	30 Mar 2005 19:02:15 -0000	1.81
+++ dlls/ntdll/file.c	15 Apr 2005 20:14:31 -0000
@@ -1480,8 +1480,7 @@

 		char bsdName[6]; /* disk#\0 */

-		strncpy(bsdName, stfs.f_mntfromname+strlen(_PATH_DEV) , 5);
-		bsdName[5] = 0;
+		lstrcpynA(bsdName, stfs.f_mntfromname+strlen(_PATH_DEV), 6);

 		kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);

Index: dlls/ntdll/time.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/time.c,v
retrieving revision 1.66
diff -u -r1.66 time.c
--- dlls/ntdll/time.c	22 Mar 2005 18:17:31 -0000	1.66
+++ dlls/ntdll/time.c	15 Apr 2005 20:14:33 -0000
@@ -866,8 +866,8 @@
         RtlInitUnicodeString( &nameW, valkey );\
         if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, KpInfo,\
                     sizeof(buf), &size )) { \
-            strncpyW( tofield, (WCHAR*) KpInfo->Data, \
-                    sizeof( tofield) / sizeof(WCHAR) ); \
+            lstrcpynW( tofield, (WCHAR*) KpInfo->Data, \
+                       sizeof( tofield) / sizeof(WCHAR) ); \
         }

         GTZIFR_N( TZStandardStartW,  tzinfo->StandardDate)
Index: dlls/oledlg/insobjdlg.c
===================================================================
RCS file: /home/wine/wine/dlls/oledlg/insobjdlg.c,v
retrieving revision 1.3
diff -u -r1.3 insobjdlg.c
--- dlls/oledlg/insobjdlg.c	24 Mar 2005 21:01:37 -0000	1.3
+++ dlls/oledlg/insobjdlg.c	15 Apr 2005 20:14:33 -0000
@@ -479,7 +479,7 @@
       WCHAR wcsFile[MAX_PATH];

       SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname);
-      strncpy(pdlgInfo->lpOleUIInsertObject->lpszFile, fname, pdlgInfo->lpOleUIInsertObject->cchFile);
+      lstrcpynA(pdlgInfo->lpOleUIInsertObject->lpszFile, fname, pdlgInfo->lpOleUIInsertObject->cchFile);

       RtlMultiByteToUnicodeN(wcsFile, MAX_PATH, NULL, fname, MAX_PATH);
       if (ERROR_SUCCESS == (hres = GetClassFile(wcsFile, &pdlgInfo->lpOleUIInsertObject->clsid)))
Index: dlls/quartz/filtermapper.c
===================================================================
RCS file: /home/wine/wine/dlls/quartz/filtermapper.c,v
retrieving revision 1.20
diff -u -r1.20 filtermapper.c
--- dlls/quartz/filtermapper.c	9 Jan 2005 18:24:41 -0000	1.20
+++ dlls/quartz/filtermapper.c	15 Apr 2005 20:14:34 -0000
@@ -732,7 +732,7 @@

     if (SUCCEEDED(hr))
     {
-        strncpyW(pCurrent, szClsidTemp, CHARS_IN_GUID);
+        memcpy(pCurrent, szClsidTemp, CHARS_IN_GUID * sizeof(WCHAR));
         pCurrent += CHARS_IN_GUID - 1;
         pCurrent[0] = '\\';

Index: dlls/shell32/debughlp.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/debughlp.c,v
retrieving revision 1.20
diff -u -r1.20 debughlp.c
--- dlls/shell32/debughlp.c	31 Mar 2005 10:05:59 -0000	1.20
+++ dlls/shell32/debughlp.c	15 Apr 2005 20:14:42 -0000
@@ -158,13 +158,13 @@
 	if (_dbg_ILIsDesktop(pidl))
 	{
 	 /* desktop */
-	  if (szOut) strncpy(szOut, "Desktop", uOutSize);
+	  if (szOut) lstrcpynA(szOut, "Desktop", uOutSize);
 	  dwReturn = strlen ("Desktop");
 	}
 	else if (( szSrc = _dbg_ILGetTextPointer(pidl) ))
 	{
 	  /* filesystem */
-	  if (szOut) strncpy(szOut, szSrc, uOutSize);
+	  if (szOut) lstrcpynA(szOut, szSrc, uOutSize);
 	  dwReturn = strlen(szSrc);
 	}
 	else if (( riid = _dbg_ILGetGUIDPointer(pidl) ))
Index: dlls/shell32/shelllink.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shelllink.c,v
retrieving revision 1.88
diff -u -r1.88 shelllink.c
--- dlls/shell32/shelllink.c	27 Mar 2005 17:54:48 -0000	1.88
+++ dlls/shell32/shelllink.c	15 Apr 2005 20:14:44 -0000
@@ -909,7 +909,7 @@
     memset( &buffer, 0, sizeof buffer );
     buffer.dbh.cbSize = sizeof buffer;
     buffer.dbh.dwSignature = magic;
-    strncpyW( buffer.szwDarwinID, string, MAX_PATH );
+    lstrcpynW( buffer.szwDarwinID, string, MAX_PATH );
     WideCharToMultiByte(CP_ACP, 0, string, -1, buffer.szDarwinID, MAX_PATH, NULL, NULL );

     return IStream_Write( stm, &buffer, buffer.dbh.cbSize, &count );
Index: dlls/shell32/shellpath.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shellpath.c,v
retrieving revision 1.100
diff -u -r1.100 shellpath.c
--- dlls/shell32/shellpath.c	16 Mar 2005 11:37:46 -0000	1.100
+++ dlls/shell32/shellpath.c	15 Apr 2005 20:14:45 -0000
@@ -1210,7 +1210,7 @@
             WCHAR szTemp[MAX_PATH];

             _SHExpandEnvironmentStrings(path, szTemp);
-            strncpyW(path, szTemp, MAX_PATH);
+            lstrcpynW(path, szTemp, MAX_PATH);
         }
         ret = RegSetValueExW(shellFolderKey, value, 0, REG_SZ, (LPBYTE)path,
          (strlenW(path) + 1) * sizeof(WCHAR));
@@ -1493,12 +1493,12 @@
     else
     {
         /* Missing or invalid value, set a default */
-        strncpyW(szValue, szDefault, MAX_PATH);
-        szValue[MAX_PATH - 1] = '\0';
+        lstrcpynW(szValue, szDefault, MAX_PATH);
         TRACE("Setting missing value %s to %s\n", debugstr_w(szValueName),
-         debugstr_w(szValue));
+                                                  debugstr_w(szValue));
         lRet = RegSetValueExW(profilesKey, szValueName, 0, REG_EXPAND_SZ,
-         (LPBYTE)szValue, (strlenW(szValue) + 1) * sizeof(WCHAR));
+                              (LPBYTE)szValue,
+                              (strlenW(szValue) + 1) * sizeof(WCHAR));
         if (lRet)
             hr = HRESULT_FROM_WIN32(lRet);
         else
Index: dlls/shell32/shlexec.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlexec.c,v
retrieving revision 1.62
diff -u -r1.62 shlexec.c
--- dlls/shell32/shlexec.c	23 Mar 2005 13:15:19 -0000	1.62
+++ dlls/shell32/shlexec.c	15 Apr 2005 20:14:46 -0000
@@ -1218,7 +1218,7 @@
 	    LPWSTR beg = wszApplicationName/*sei_tmp.lpFile*/;
 	    for(s=beg; (space=strchrW(s, ' ')); s=space+1) {
 		int idx = space-sei_tmp.lpFile;
-		strncpyW(buffer, sei_tmp.lpFile, idx);
+		memcpy(buffer, sei_tmp.lpFile, idx * sizeof(WCHAR));
 		buffer[idx] = '\0';

 		/*FIXME This finds directory paths if the targeted file name contains spaces. */
@@ -1296,7 +1296,7 @@

         TRACE("Got URL: %s\n", debugstr_w(lpFile));
         /* Looking for ...protocol\shell\lpOperation\command */
-        strncpyW(lpstrProtocol, lpFile, iSize);
+        memcpy(lpstrProtocol, lpFile, iSize*sizeof(WCHAR));
         lpstrProtocol[iSize] = '\0';
         strcatW(lpstrProtocol, wShell);
         strcatW(lpstrProtocol, sei_tmp.lpVerb? sei_tmp.lpVerb: wszOpen);
Index: dlls/shell32/systray.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/systray.c,v
retrieving revision 1.28
diff -u -r1.28 systray.c
--- dlls/shell32/systray.c	6 Dec 2004 11:51:29 -0000	1.28
+++ dlls/shell32/systray.c	15 Apr 2005 20:14:46 -0000
@@ -256,8 +256,7 @@
 {
   TTTOOLINFOA ti;

-  strncpy(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip));
-  ptrayItem->notifyIcon.szTip[sizeof(ptrayItem->notifyIcon.szTip)-1]=0;
+  lstrcpynA(ptrayItem->notifyIcon.szTip, szTip, sizeof(ptrayItem->notifyIcon.szTip));

   ti.cbSize = sizeof(TTTOOLINFOA);
   ti.uFlags = 0;
Index: dlls/user/edit.c
===================================================================
RCS file: /home/wine/wine/dlls/user/edit.c,v
retrieving revision 1.22
diff -u -r1.22 edit.c
--- dlls/user/edit.c	23 Mar 2005 13:15:18 -0000	1.22
+++ dlls/user/edit.c	15 Apr 2005 20:14:56 -0000
@@ -3052,7 +3052,7 @@
 		bufl = e - s;
 		buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
 		if (!buf) return;
-		strncpyW(buf, es->text + s, bufl);
+		memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
 		buf[bufl] = 0; /* ensure 0 termination */
 		/* now delete */
 		strcpyW(es->text + s, es->text + e);
@@ -3113,7 +3113,7 @@
 			if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
 				/* undo-buffer is extended to the right */
 				EDIT_MakeUndoFit(es, utl + e - s);
-				strncpyW(es->undo_text + utl, buf, e - s + 1);
+				memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
 				(es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
 			} else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
 				/* undo-buffer is extended to the left */
@@ -3126,7 +3126,7 @@
 			} else {
 				/* new undo-buffer */
 				EDIT_MakeUndoFit(es, e - s);
-				strncpyW(es->undo_text, buf, e - s + 1);
+				memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
 				es->undo_text[e - s] = 0; /* ensure 0 termination */
 				es->undo_position = s;
 			}
@@ -3932,13 +3932,15 @@
 	INT e = max(es->selection_start, es->selection_end);
 	HGLOBAL hdst;
 	LPWSTR dst;
+	DWORD len;

 	if (e == s) return;

-	hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (DWORD)(e - s + 1) * sizeof(WCHAR));
+	len = e - s;
+	hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len + 1) * sizeof(WCHAR));
 	dst = GlobalLock(hdst);
-	strncpyW(dst, es->text + s, e - s);
-	dst[e - s] = 0; /* ensure 0 termination */
+	memcpy(dst, es->text + s, len * sizeof(WCHAR));
+	dst[len] = 0; /* ensure 0 termination */
 	TRACE("%s\n", debugstr_w(dst));
 	GlobalUnlock(hdst);
 	OpenClipboard(es->hwndSelf);
Index: dlls/winedos/int21.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/int21.c,v
retrieving revision 1.76
diff -u -r1.76 int21.c
--- dlls/winedos/int21.c	14 Jan 2005 16:21:07 -0000	1.76
+++ dlls/winedos/int21.c	15 Apr 2005 20:15:01 -0000
@@ -3434,7 +3434,7 @@
     *(WORD *)dataptr = 0;
     memcpy(dataptr + 2, &serial, sizeof(DWORD));
     WideCharToMultiByte(CP_OEMCP, 0, label, 11, dataptr + 6, 11, NULL, NULL);
-    strncpy(dataptr + 17, "FAT16   ", 8);
+    memcpy(dataptr + 17, "FAT16   ", 8);
     return 1;
 }

Index: dlls/wininet/dialogs.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/dialogs.c,v
retrieving revision 1.9
diff -u -r1.9 dialogs.c
--- dlls/wininet/dialogs.c	23 Sep 2004 22:54:58 -0000	1.9
+++ dlls/wininet/dialogs.c	15 Apr 2005 20:15:02 -0000
@@ -76,7 +76,7 @@
     if (NULL == hIC)
 	return FALSE;

-    strncpyW(szBuf, hIC->lpszProxy, sz);
+    lstrcpynW(szBuf, hIC->lpszProxy, sz);

     /* FIXME: perhaps it would be better to use InternetCrackUrl here */
     p = strchrW(szBuf, ':');
Index: dlls/wininet/internet.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/internet.c,v
retrieving revision 1.118
diff -u -r1.118 internet.c
--- dlls/wininet/internet.c	30 Mar 2005 17:08:32 -0000	1.118
+++ dlls/wininet/internet.c	15 Apr 2005 20:15:09 -0000
@@ -1190,6 +1190,13 @@
  *
  * Helper function for InternetCrackUrlW
  *
+ * PARAMS
+ *     lppszComponent [O] Holds the returned string
+ *     dwComponentLen [I] Holds the size of lppszComponent
+ *                    [O] Holds the length of the string in lppszComponent without '\0'
+ *     lpszStart      [I] Holds the string to copy from
+ *     len            [I] Holds the length of lpszStart without '\0'
+ *
  * RETURNS
  *    TRUE on success
  *    FALSE on failure
@@ -1212,7 +1219,7 @@
         else
         {
             DWORD ncpylen = min((*dwComponentLen)-1, len);
-            strncpyW(*lppszComponent, lpszStart, ncpylen);
+            memcpy(*lppszComponent, lpszStart, ncpylen*sizeof(WCHAR));
             (*lppszComponent)[ncpylen] = '\0';
             *dwComponentLen = ncpylen;
         }
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	15 Apr 2005 20:15:11 -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 */
Index: dlls/winmm/wineoss/audio.c
===================================================================
RCS file: /home/wine/wine/dlls/winmm/wineoss/audio.c,v
retrieving revision 1.159
diff -u -r1.159 audio.c
--- dlls/winmm/wineoss/audio.c	17 Mar 2005 18:56:14 -0000	1.159
+++ dlls/winmm/wineoss/audio.c	15 Apr 2005 20:15:13 -0000
@@ -701,7 +701,7 @@
         if ((mixer = open(ossdev->mixer_name, O_RDONLY|O_NDELAY)) >= 0) {
             mixer_info info;
             if (ioctl(mixer, SOUND_MIXER_INFO, &info) >= 0) {
-                strncpy(ossdev->ds_desc.szDesc, info.name, sizeof(info.name));
+                lstrcpynA(ossdev->ds_desc.szDesc, info.name, sizeof(info.name));
                 strcpy(ossdev->ds_desc.szDrvname, "wineoss.drv");
                 MultiByteToWideChar(CP_ACP, 0, info.name, sizeof(info.name),
                                     ossdev->out_caps.szPname,
Index: programs/winecfg/drivedetect.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/drivedetect.c,v
retrieving revision 1.5
diff -u -r1.5 drivedetect.c
--- programs/winecfg/drivedetect.c	25 Feb 2005 13:58:45 -0000	1.5
+++ programs/winecfg/drivedetect.c	15 Apr 2005 20:15:20 -0000
@@ -310,7 +310,7 @@
             return FALSE;
         }

-        strncpy(label, "Drive X", 8);
+        memcpy(label, "Drive X", 8);
         label[6] = letter;

         WINE_TRACE("adding drive %c for %s, type %s with label %s\n", letter, ent->mnt_dir, ent->mnt_type,label);
Index: tools/sfnt2fnt.c
===================================================================
RCS file: /home/wine/wine/tools/sfnt2fnt.c,v
retrieving revision 1.3
diff -u -r1.3 sfnt2fnt.c
--- tools/sfnt2fnt.c	19 Nov 2004 18:23:52 -0000	1.3
+++ tools/sfnt2fnt.c	15 Apr 2005 20:15:23 -0000
@@ -207,12 +207,13 @@
     num_names = FT_Get_Sfnt_Name_Count(face);
     for(i = 0; i <num_names; i++) {
         FT_Get_Sfnt_Name(face, i, &sfntname);
-        strncpy(namebuf, sfntname.string, sfntname.string_len);
+        memcpy(namebuf, sfntname.string, sfntname.string_len);
         namebuf[sfntname.string_len] = '\0';
-        if(sfntname.platform_id == 1 && sfntname.encoding_id == 0 && sfntname.language_id == 0 && sfntname.name_id == 0) {
-            strncpy(hdr.dfCopyright, namebuf, 60);
-            hdr.dfCopyright[59] = '\0';
-        }
+        if(sfntname.platform_id == 1 && sfntname.encoding_id == 0 &&
+           sfntname.language_id == 0 && sfntname.name_id == 0) {
+            strncpy(hdr.dfCopyright, namebuf, 60);
+            hdr.dfCopyright[59] = '\0';
+	}
     }

     os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);





More information about the wine-patches mailing list