]> granicus.if.org Git - shadow/commitdiff
newuidmap,newgidmap: Correct the range size sanity check in get_map_ranges 4.2.1
authorEric W. Biederman <ebiederm@xmission.com>
Sun, 8 Sep 2013 09:49:52 +0000 (02:49 -0700)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 10 Sep 2013 22:51:40 +0000 (17:51 -0500)
The number of ranges should be the ceiling of the number of arguments divided
by three.

Without this fix newuidmap and newgidmap always report and error and fail,
which is very much not what we want.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
libmisc/idmapping.c

index 81e85d5faaf67296e6fb30ecc765240280390a82..714c29ebd9fd84d7d93d6831d399c60cebc5f420 100644 (file)
@@ -47,7 +47,7 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
                return NULL;
        }
 
-       if (ranges != ((argc - 2) + 2) / 3) {
+       if (ranges != ((argc + 2) / 3)) {
                fprintf(stderr, "%s: ranges: %u is wrong for argc: %d\n", Prog, ranges, argc);
                return NULL;
        }