[2/2] kernel32: Check for invalid filename pointers in CreateFileA for Win9x compatibility.

Sebastian Lackner sebastian at fds-team.de
Wed Mar 30 23:04:43 CDT 2016


From: Michael Müller <michael at fds-team.de>

Signed-off-by: Michael Müller <michael at fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---

Michael wrote a long explanation in his original commit:
    The demo version of Test Drive 5 loops through a list of filenames and opens
    them using CreateFileA. The stop condition is not correct and the game reads
    past the end of the array and therefore passes several invalid pointers to
    the CreateFileA API. Windows 98 catches those invalid pointers and the game
    can load sucessfully. This commit adds the same behavior when setting the
    Windows version to 9x.

 dlls/kernel32/file.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/dlls/kernel32/file.c b/dlls/kernel32/file.c
index b6dba6a..750a8ac 100644
--- a/dlls/kernel32/file.c
+++ b/dlls/kernel32/file.c
@@ -1629,6 +1629,7 @@ HANDLE WINAPI CreateFileA( LPCSTR filename, DWORD access, DWORD sharing,
 {
     WCHAR *nameW;
 
+    if ((GetVersion() & 0x80000000) && IsBadStringPtrA(filename, -1)) return INVALID_HANDLE_VALUE;
     if (!(nameW = FILE_name_AtoW( filename, FALSE ))) return INVALID_HANDLE_VALUE;
     return CreateFileW( nameW, access, sharing, sa, creation, attributes, template );
 }
-- 
2.7.1



More information about the wine-patches mailing list