mirror of https://github.com/ipxe/ipxe.git
[build] Fix signed/unsigned division in util/zbin.c
Commit b149a99
([build] Round up SUBx deltas) introduced a
signed/unsigned issue that affects gPXE images built on 32-bit hosts.
The zbin fixup utility performed an unsigned division, which led to
.usb images with an incorrect number of sectors to load.
The issue snuck by on 64-bit hosts since uint32_t is promoted to long.
On 32-bit hosts it is promoted to unsigned long.
Modified-by: Michael Brown <mcb30@etherboot.org>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
pull/1/head
parent
4b8e021161
commit
9b964dec36
|
@ -213,7 +213,8 @@ static int process_zinfo_subtract ( struct input_file *input,
|
||||||
size_t datasize ) {
|
size_t datasize ) {
|
||||||
size_t offset = subtract->offset;
|
size_t offset = subtract->offset;
|
||||||
void *target;
|
void *target;
|
||||||
long delta;
|
signed long raw_delta;
|
||||||
|
signed long delta;
|
||||||
unsigned long old;
|
unsigned long old;
|
||||||
unsigned long new;
|
unsigned long new;
|
||||||
|
|
||||||
|
@ -224,9 +225,9 @@ static int process_zinfo_subtract ( struct input_file *input,
|
||||||
}
|
}
|
||||||
|
|
||||||
target = ( output->buf + offset );
|
target = ( output->buf + offset );
|
||||||
delta = ( ( align ( output->len, subtract->divisor ) -
|
raw_delta = ( align ( output->len, subtract->divisor ) -
|
||||||
align ( input->len, subtract->divisor ) )
|
align ( input->len, subtract->divisor ) );
|
||||||
/ subtract->divisor );
|
delta = ( raw_delta / ( ( signed long ) subtract->divisor ) );
|
||||||
|
|
||||||
switch ( datasize ) {
|
switch ( datasize ) {
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
Loading…
Reference in New Issue