mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 09:01:24 +03:00
[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:
@@ -2135,7 +2135,7 @@ static int hermon_map_vpm ( struct hermon *hermon,
|
|||||||
if ( ( low - size ) >= start ) {
|
if ( ( low - size ) >= start ) {
|
||||||
low -= size;
|
low -= size;
|
||||||
pa = low;
|
pa = low;
|
||||||
} else if ( ( high + size ) <= end ) {
|
} else if ( high <= ( end - size ) ) {
|
||||||
pa = high;
|
pa = high;
|
||||||
high += size;
|
high += size;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user