[PATCH] shell32: use flexible arrays to avoid fortify failures

Mike Frysinger vapier at gentoo.org
Tue Sep 14 08:44:35 CDT 2010


Newer versions of gcc/glibc with fortify checks enabled will complain
about the handling of the network's szNames field.  Currently it is
always defined with a length of one which means writing more then a
single byte will trigger:
	In function 'strcpy', inlined from '_ILCreateEntireNetwork' at
	dlls/shell32/pidl.c:1762:15:
	warning: call to __builtin___strcpy_chk will always overflow destination buffer
and then at runtime, we hit an abort().

Since this field is really serving as the header to an arbitrary buffer,
using a flexible array instead should solve the issue.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 dlls/shell32/pidl.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/shell32/pidl.h b/dlls/shell32/pidl.h
index 3dbfaa6..bbfacef 100644
--- a/dlls/shell32/pidl.h
+++ b/dlls/shell32/pidl.h
@@ -172,12 +172,12 @@ typedef struct tagPIDLDATA
 	  struct tagFileStruct file;
 	  struct
 	  { WORD dummy;		/*01*/
-	    CHAR szNames[1];	/*03*/
+	    CHAR szNames[];	/*03*/
 	  } network;
 	  struct
 	  { WORD dummy;		/*01*/
 	    DWORD dummy1;	/*02*/
-	    CHAR szName[1];	/*06*/ /* terminated by 0x00 0x00 */
+	    CHAR szName[];	/*06*/ /* terminated by 0x00 0x00 */
 	  } htmlhelp;
 	  struct tagPIDLCPanelStruct cpanel;
           struct tagValueW valueW;
-- 
1.7.2




More information about the wine-devel mailing list