[Pkg-shadow-devel] [PATCH] newuidmap, newgidmap: Correct the range size sanity check in get_map_ranges

Serge Hallyn serge.hallyn at ubuntu.com
Mon Sep 9 14:08:02 UTC 2013


Quoting Eric W. Biederman (ebiederm at xmission.com):
> 
> 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.

Are you sure?  Without looking back at the code, I can say I've used
them quite a bit and never seen an error.  When I originally looked
at the code the -2 + 2 did annoy me, but I assumed it was supposed to
remind you of something :)

Can you give an example command line that fails for you?

> Signed-off-by: "Eric W. Biederman" <ebiederm at xmission.com>
> ---
>  libmisc/idmapping.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libmisc/idmapping.c b/libmisc/idmapping.c
> index 81e85d5..714c29e 100644
> --- a/libmisc/idmapping.c
> +++ b/libmisc/idmapping.c
> @@ -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;
>  	}
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> Pkg-shadow-devel mailing list
> Pkg-shadow-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-shadow-devel



More information about the Pkg-shadow-devel mailing list