From: Michael Brown Date: Wed, 27 Aug 2008 19:36:30 +0000 (+0100) Subject: [util] Fix interpretation of short jumps in Option::ROM X-Git-Tag: v0.9.4~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd5189a96d88a27f8c7da29491876ec3790af138;p=thirdparty%2Fipxe.git [util] Fix interpretation of short jumps in Option::ROM Option::ROM was assuming that ROM images using a short jump instruction for the init entry point would have a zero byte at offset 5; this is not necessarily true. --- diff --git a/src/util/Option/ROM.pm b/src/util/Option/ROM.pm index 7a1bb8838..a86d32620 100644 --- a/src/util/Option/ROM.pm +++ b/src/util/Option/ROM.pm @@ -192,10 +192,12 @@ sub unpack_init { my $instr = shift; # Accept both short and near jumps - ( my $jump, my $offset ) = unpack ( "CS", $instr ); + my $jump = unpack ( "C", $instr ); if ( $jump == JMP_SHORT ) { + my $offset = unpack ( "xC", $instr ); return ( $offset + 5 ); } elsif ( $jump == JMP_NEAR ) { + my $offset = unpack ( "xS", $instr ); return ( $offset + 6 ); } elsif ( $jump == 0 ) { return 0;