libxl: fix unsigned less-than-0 comparison in e820_sanitize
authorMatthew Daley <mattd@bugfuzz.com>
Sun, 1 Dec 2013 10:14:55 +0000 (23:14 +1300)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 13 Dec 2013 17:30:52 +0000 (17:30 +0000)
Both src[i].size and delta are unsigned, so checking their difference
for being less than 0 doesn't work.

Coverity-ID: 1055615
Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_x86.c

index e1c183fe7331fa92a2a7ac68c5a61a9a8596822a..b11d0364dfd651321a0b44d0e4c020aa2fa8ce0a 100644 (file)
@@ -125,7 +125,7 @@ static int e820_sanitize(libxl_ctx *ctx, struct e820entry src[],
             src[i].type = E820_UNUSABLE;
             delta = ram_end - src[i].addr;
             /* The end < ram_end should weed this out */
-            if (src[i].size - delta < 0)
+            if (src[i].size < delta)
                 src[i].type = 0;
             else {
                 src[i].size -= delta;