userns: add argument sanity checking
In find_new_sub_{u,g}ids, check for min, count and max values. In idmapping.c:get_map_ranges(), make sure that the value passed in for ranges did not overflow. Couldn't happen with the current code, but this is a sanity check for any future potential mis-uses. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
@@ -41,6 +41,16 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
|
||||
struct map_range *mappings, *mapping;
|
||||
int idx, argidx;
|
||||
|
||||
if (ranges < 0 || argc < 0) {
|
||||
fprintf(stderr, "%s: error calculating number of arguments\n", Prog);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ranges != ((argc - 2) + 2) / 3) {
|
||||
fprintf(stderr, "%s: ranges: %u is wrong for argc: %d\n", Prog, ranges, argc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ranges * 3) > argc) {
|
||||
fprintf(stderr, "ranges: %u argc: %d\n",
|
||||
ranges, argc);
|
||||
|
Reference in New Issue
Block a user