Pārlūkot izejas kodu

[modrom] Avoid clobbering near jump with checksum

A jump instruction starts at the third byte of an option ROM image, and
it is required that the bytes in the whole image add up to zero. To
achieve this, a checksum byte is usually placed after the jump. The jump
can be either a short jump (2 bytes, EB xx) or a near jump (3 bytes,
E9 xx xx). gPXE's romprefix.S uses a near jump, but modrom.pl assumed
a short jump, and clobbered the high byte of the offset. This caused
modrom-modified gPXE ROM images to crash the system during POST.

Fix by making modrom.pl place the checksum at byte 6, like makerom.pl does.

Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v0.9.9
Joshua Oreman 15 gadus atpakaļ
vecāks
revīzija
b0b0b8f65c
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 2
    2
      src/util/modrom.pl

+ 2
- 2
src/util/modrom.pl Parādīt failu

@@ -131,9 +131,9 @@ sub writerom ($$) {
131 131
 sub checksum ($) {
132 132
 	my ($romref) = @_;
133 133
 
134
-	substr($$romref, 5, 1) = "\x00";
134
+	substr($$romref, 6, 1) = "\x00";
135 135
 	my $sum = unpack('%8C*', $$romref);
136
-	substr($$romref, 5, 1) = chr(256 - $sum);
136
+	substr($$romref, 6, 1) = chr(256 - $sum);
137 137
 	# Double check
138 138
 	$sum = unpack('%8C*', $$romref);
139 139
 	if ($sum != 0) {

Notiek ielāde…
Atcelt
Saglabāt