[PATCH] shell32: replace strcpy by memcpy due to slightly undefined struct handling

Marcus Meissner meissner at suse.de
Mon Feb 15 10:23:05 CST 2010


Hi,

Writing over the end of a struct is only clearly defined if the struct
is standalone and not contained in another union / struct.

So for gcc 4.5 the strcpy triggers a fortify overflow error and we
better use memcpy here.

Adjusted to use strlen() after comments.

Ciao, Marcus
---
 dlls/shell32/pidl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/shell32/pidl.c b/dlls/shell32/pidl.c
index 3e61144..4b8858b 100644
--- a/dlls/shell32/pidl.c
+++ b/dlls/shell32/pidl.c
@@ -1600,13 +1600,13 @@ LPITEMIDLIST _ILCreateEntireNetwork(void)
 
     TRACE("\n");
 
-    pidlOut = _ILAlloc(PT_NETWORK, FIELD_OFFSET(PIDLDATA, u.network.szNames[sizeof("Entire Network")]));
+    pidlOut = _ILAlloc(PT_NETWORK, FIELD_OFFSET(PIDLDATA, u.network.szNames[strlen("Entire Network")+1]));
     if (pidlOut)
     {
         LPPIDLDATA pData = _ILGetDataPointer(pidlOut);
 
         pData->u.network.dummy = 0;
-        strcpy(pData->u.network.szNames, "Entire Network");
+        memcpy(pData->u.network.szNames, "Entire Network", strlen("Entire Network")+1);
     }
     return pidlOut;
 }
-- 
1.6.6.1



More information about the wine-patches mailing list