Alexandre Julliard : server: Fix the returned error code for an invalid NT header offset.

Alexandre Julliard julliard at winehq.org
Mon Nov 25 09:12:27 CST 2019


Module: wine
Branch: stable
Commit: ef2cf798b3c28b9918a89157c7bbcd1822a67246
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ef2cf798b3c28b9918a89157c7bbcd1822a67246

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jun 13 20:30:35 2019 +0200

server: Fix the returned error code for an invalid NT header offset.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47359
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit f59d05223d68522853dae6aa52f2308da759a94b)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/kernel32/tests/loader.c | 5 +++++
 server/mapping.c             | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 01c7cfa8a9..5dd46f98e9 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -992,6 +992,11 @@ static void test_Loader(void)
     }
     ((IMAGE_OS2_HEADER *)&nt_header)->ne_exetyp = ((IMAGE_OS2_HEADER *)&nt_header_template)->ne_exetyp;
 
+    dos_header.e_lfanew = 0x98760000;
+    status = map_image_section( &nt_header, &section, section_data, __LINE__ );
+    ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection error %08x\n", status );
+
+    dos_header.e_lfanew = sizeof(dos_header);
     nt_header.Signature = 0xdeadbeef;
     status = map_image_section( &nt_header, &section, section_data, __LINE__ );
     ok( status == STATUS_INVALID_IMAGE_PROTECT, "NtCreateSection error %08x\n", status );
diff --git a/server/mapping.c b/server/mapping.c
index ea49e1ab43..cc06106e3f 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -581,7 +581,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
     pos = dos.e_lfanew;
 
     size = pread( unix_fd, &nt, sizeof(nt), pos );
-    if (size < sizeof(nt.Signature) + sizeof(nt.FileHeader)) return STATUS_INVALID_IMAGE_FORMAT;
+    if (size < sizeof(nt.Signature) + sizeof(nt.FileHeader)) return STATUS_INVALID_IMAGE_PROTECT;
     /* zero out Optional header in the case it's not present or partial */
     size = min( size, sizeof(nt.Signature) + sizeof(nt.FileHeader) + nt.FileHeader.SizeOfOptionalHeader );
     if (size < sizeof(nt)) memset( (char *)&nt + size, 0, sizeof(nt) - size );




More information about the wine-cvs mailing list