david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[hermon] Avoid potential integer overflow when calculating memory mappings

When the area to be mapped straddles the 2GB boundary, the expression
(high+size) will overflow on the first loop iteration.  Fix by using
(end-size), which cannot underflow.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2017-03-21 11:46:17 +02:00
parent de2c6fa240
commit 6ee62eb242
1 changed files with 1 additions and 1 deletions

View File

@ -2135,7 +2135,7 @@ static int hermon_map_vpm ( struct hermon *hermon,
if ( ( low - size ) >= start ) {
low -= size;
pa = low;
} else if ( ( high + size ) <= end ) {
} else if ( high <= ( end - size ) ) {
pa = high;
high += size;
} else {