[PATCH] ntdll: Pad the FILE_*_DIRECTORY_INFORMATION with zero bytes

Martin Storsjo martin at martin.st
Mon May 12 13:12:38 CDT 2014


Instead of memcpying in whatever uninitialized data there was at
the end of long_nameW, memset the tail of the struct to zero
instead.

This fixes running cl.exe from MSVC 2013 with native
msvcr120/msvcp120, fixing bug 35335.

MSVC 2013 (or msvcr120?) seems to use NtQueryDirectoryFile to
iterate through the headers in directories in the include path,
and prior to this change, the file names found during iteration
could get a suffix consisting of an uninitialized WCHAR.
---
 dlls/ntdll/directory.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/directory.c b/dlls/ntdll/directory.c
index 890fb71..7ccc36c 100644
--- a/dlls/ntdll/directory.c
+++ b/dlls/ntdll/directory.c
@@ -1484,7 +1484,9 @@ static union file_directory_info *append_entry( void *info_ptr, IO_STATUS_BLOCK
         assert(0);
         return NULL;
     }
-    memcpy( filename, long_nameW, total_len - ((char *)filename - (char *)info) );
+    memcpy( filename, long_nameW, long_len * sizeof(WCHAR) );
+    memset( filename + long_len * sizeof(WCHAR), 0,
+            total_len - long_len * sizeof(WCHAR) );
     io->Information += total_len;
     return info;
 }
-- 
1.8.1.2




More information about the wine-patches mailing list