From 47cd83ae14f4de3391e86d4d585c6f522d05c1c1 Mon Sep 17 00:00:00 2001 From: sergei Date: Tue, 30 Oct 2012 09:00:13 +0000 Subject: [PATCH] * Fetch PECOFF section sizes correctly (not including zero padding), resolves #22788. git-svn-id: trunk@22879 - --- rtl/inc/exeinfo.pp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rtl/inc/exeinfo.pp b/rtl/inc/exeinfo.pp index d9daa9ac05..e1edfa65e1 100644 --- a/rtl/inc/exeinfo.pp +++ b/rtl/inc/exeinfo.pp @@ -379,7 +379,17 @@ begin if asecname=secname then begin secofs:=cardinal(sechdr.datapos) + E.ImgOffset; +{$ifdef GO32V2} seclen:=sechdr.datalen; +{$else GO32V2} + { In PECOFF, datalen includes file padding up to the next section. + vsize is the actual payload size if it does not exceed datalen, + otherwise it is .bss (or alike) section that we should ignore. } + if sechdr.vsize<=sechdr.datalen then + seclen:=sechdr.vsize + else + exit; +{$endif GO32V2} FindSectionCoff:=true; exit; end;