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

Alexandre Julliard julliard at winehq.org
Thu Jun 13 15:40:38 CDT 2019


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

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>

---

 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 bc6f4ab..eb02e95 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -1153,6 +1153,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 8a6c4f1..0728fdc 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -593,7 +593,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
     pos = mz.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