From c822585e777621e491e1207ec371d303624c7870 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 6 Apr 2017 16:20:50 -0700 Subject: [PATCH] getpearch.pl: the PE header offset may be > 255 The PE header offset field is not a byte; assume it is a long. The specification doesn't actually say... Signed-off-by: H. Peter Anvin --- nsis/getpearch.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nsis/getpearch.pl b/nsis/getpearch.pl index 25155536..77fdb575 100644 --- a/nsis/getpearch.pl +++ b/nsis/getpearch.pl @@ -5,6 +5,7 @@ # use strict; +use bytes; my %archnames = ( 0x01de => 'am33', @@ -38,8 +39,8 @@ read($fh, my $mz, 2); exit 0 if ($mz ne 'MZ'); exit 0 unless (seek($fh, 0x3c, 0)); -exit 0 unless (read($fh, my $pe_offset, 1) == 1); -$pe_offset = unpack("C", $pe_offset); +exit 0 unless (read($fh, my $pe_offset, 4) == 4); +$pe_offset = unpack("V", $pe_offset); exit 0 unless (seek($fh, $pe_offset, 0)); read($fh, my $pe, 4);