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@winehq.org>
(cherry picked from commit f59d05223d)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Alexandre Julliard 2019-06-13 20:30:35 +02:00 committed by Michael Stefaniuc
parent 1ea857f188
commit ef2cf798b3
2 changed files with 6 additions and 1 deletions

View File

@ -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 );

View File

@ -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 );