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

Alexandre Julliard julliard at winehq.org
Fri Aug 7 10:42:29 CDT 2020


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

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>
(cherry picked from commit ae9eb36e21c9b8e31b1e4a4c1eb6deae9b90262d)
Signed-off-by: Michael Stefaniuc <mstefani 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 6990a1913d..ac144b1bb9 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -579,7 +579,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();
 
@@ -595,7 +595,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