Dmitry Timoshkov : server: All fields up to CheckSum are mandatory regardless of SizeOfOptionalHeader value.

Alexandre Julliard julliard at winehq.org
Fri May 15 16:55:06 CDT 2020


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Wed May  6 15:15:54 2020 +0800

server: All fields up to CheckSum are mandatory regardless of SizeOfOptionalHeader value.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42125
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 server/mapping.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/server/mapping.c b/server/mapping.c
index 6970c86ffc..ffd20450df 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -580,7 +580,7 @@ static unsigned int get_image_params( struct mapping *mapping, file_pos_t file_s
         } opt;
     } nt;
     off_t pos;
-    int size;
+    int size, opt_size;
     size_t mz_size, clr_va, clr_size;
     unsigned int i, cpu_mask = get_supported_cpu_mask();
 
@@ -596,7 +596,8 @@ 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_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 );
+    opt_size = max( nt.FileHeader.SizeOfOptionalHeader, offsetof( IMAGE_OPTIONAL_HEADER32, CheckSum ));
+    size = min( size, sizeof(nt.Signature) + sizeof(nt.FileHeader) + opt_size );
     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