Browse Source

[arbel] 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>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
a5affc832e
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      src/drivers/infiniband/arbel.c

+ 1
- 1
src/drivers/infiniband/arbel.c View File

1994
 		if ( ( low - size ) >= start ) {
1994
 		if ( ( low - size ) >= start ) {
1995
 			low -= size;
1995
 			low -= size;
1996
 			pa = low;
1996
 			pa = low;
1997
-		} else if ( ( high + size ) <= end ) {
1997
+		} else if ( high <= ( end - size ) ) {
1998
 			pa = high;
1998
 			pa = high;
1999
 			high += size;
1999
 			high += size;
2000
 		} else {
2000
 		} else {

Loading…
Cancel
Save