get_map_ranges: check for overflow

The kernel accepts u32 values, so make sure that userspace
is not passing large values.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
This commit is contained in:
Serge Hallyn 2016-07-31 12:55:44 -05:00
parent 9bf01bf010
commit 7f5a14817d

View File

@ -83,6 +83,16 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
free(mappings);
return NULL;
}
if (mapping->upper > UINT_MAX ||
mapping->lower > UINT_MAX ||
mapping->count > UINT_MAX) {
free(mappings);
return NULL;
}
if (mapping->lower + mapping->count < mapping->lower) {
free(mapping);
return NULL;
}
}
return mappings;
}