Piotr Caban : server: Fix loading of IMAGE_OPTIONAL_HEADER.
Alexandre Julliard
julliard at winehq.org
Mon Aug 8 11:09:29 CDT 2016
Module: wine
Branch: master
Commit: 84b3218ed6ad5975f537481edf2f61fb26bedb8b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=84b3218ed6ad5975f537481edf2f61fb26bedb8b
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Aug 8 16:20:50 2016 +0200
server: Fix loading of IMAGE_OPTIONAL_HEADER.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/loader.c | 10 +++++++---
server/mapping.c | 2 +-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 6ee9e38..7585b9b 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -264,9 +264,13 @@ static void query_image_section( int id, const char *dll_name, const IMAGE_NT_HE
ok( image.CommittedStackSize == nt_header->OptionalHeader.SizeOfStackCommit || broken(truncated),
"%u: CommittedStackSize wrong %lx / %lx\n", id,
image.CommittedStackSize, (SIZE_T)nt_header->OptionalHeader.SizeOfStackCommit );
- ok( image.SubSystemType == nt_header->OptionalHeader.Subsystem || broken(truncated),
- "%u: SubSystemType wrong %08x / %08x\n", id,
- image.SubSystemType, nt_header->OptionalHeader.Subsystem );
+ if (truncated)
+ ok( !image.SubSystemType || broken(truncated),
+ "%u: SubSystemType wrong %08x / 00000000\n", id, image.SubSystemType );
+ else
+ ok( image.SubSystemType == nt_header->OptionalHeader.Subsystem,
+ "%u: SubSystemType wrong %08x / %08x\n", id,
+ image.SubSystemType, nt_header->OptionalHeader.Subsystem );
ok( image.SubsystemVersionLow == nt_header->OptionalHeader.MinorSubsystemVersion,
"%u: SubsystemVersionLow wrong %04x / %04x\n", id,
image.SubsystemVersionLow, nt_header->OptionalHeader.MinorSubsystemVersion );
diff --git a/server/mapping.c b/server/mapping.c
index b68f281..f82907b 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -399,7 +399,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
size = pread( unix_fd, &nt, sizeof(nt), pos );
if (size < sizeof(nt.Signature) + sizeof(nt.FileHeader)) return STATUS_INVALID_IMAGE_FORMAT;
/* zero out Optional header in the case it's not present or partial */
- size = min( size, nt.FileHeader.SizeOfOptionalHeader );
+ size = min( size, sizeof(nt.Signature) + sizeof(nt.FileHeader) + nt.FileHeader.SizeOfOptionalHeader );
if (size < sizeof(nt)) memset( (char *)&nt + size, 0, sizeof(nt) - size );
if (nt.Signature != IMAGE_NT_SIGNATURE)
{
More information about the wine-cvs
mailing list