[PATCH] kernel32: Prevent MODULE_Decide_OS2_OldWin() fallthrough which causes

Martin Payne development at martinpayne.me.uk
Wed Dec 13 04:21:00 CST 2017


valid non-Win16 New Executables (e.g. OS/2) to be reported as broken.
Clarified FIXME and made whitespace consistent around code which was
updated.

Tested on Fedora 26 x86.

Signed-off-by: Martin Payne <development at martinpayne.me.uk>
---
 dlls/kernel32/module.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c
index b4d5fe7c2e..93ac32f6d3 100644
--- a/dlls/kernel32/module.c
+++ b/dlls/kernel32/module.c
@@ -253,8 +253,8 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
 /* Check whether a file is an OS/2 or a very old Windows executable
  * by testing on import of KERNEL.
  *
- * FIXME: is reading the module imports the only way of discerning
- *        old Windows binaries from OS/2 ones ? At least it seems so...
+ * Reading the module imports is the only reasonable way of discerning
+ * old Windows binaries from OS/2 ones.
  */
 static DWORD MODULE_Decide_OS2_OldWin(HANDLE hfile, const IMAGE_DOS_HEADER *mz, const IMAGE_OS2_HEADER *ne)
 {
@@ -281,16 +281,18 @@ static DWORD MODULE_Decide_OS2_OldWin(HANDLE hfile, const IMAGE_DOS_HEADER *mz,
 
     for (i=0; i < ne->ne_cmod; i++)
     {
-	LPSTR module = &nametab[modtab[i]];
-	TRACE("modref: %.*s\n", module[0], &module[1]);
-	if (!(strncmp(&module[1], "KERNEL", module[0])))
-	{ /* very old Windows file */
-	    MESSAGE("This seems to be a very old (pre-3.0) Windows executable. Expect crashes, especially if this is a real-mode binary !\n");
+        LPSTR module = &nametab[modtab[i]];
+        TRACE("modref: %.*s\n", module[0], &module[1]);
+        if (!(strncmp(&module[1], "KERNEL", module[0])))
+        { /* very old Windows file */
+            MESSAGE("This seems to be a very old (pre-3.0) Windows executable. Expect crashes, especially if this is a real-mode binary !\n");
             ret = BINARY_WIN16;
-	    goto good;
-	}
+            break;
+        }
     }
 
+    goto good;
+
 broken:
     ERR("Hmm, an error occurred. Is this binary file broken?\n");
 
-- 
2.15.1.windows.2




More information about the wine-devel mailing list