Re: [PATCH 02/19] mkfs: sanitise ftype parameter values.

Eric Sandeen
2016-03-24T16:33:55Z

On 3/24/16 6:15 AM, jtulak@redhat.com wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Because passing "-n ftype=2" should fail.

but passing crc=1 ftype=1 shouldn't fail, should it?
Seems like it will here.

-Eric

> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> Reviewed-by: Brian Foster <bfoster@redhat.com>
> ---
> mkfs/xfs_mkfs.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 36e5b4f..979a860 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1596,7 +1596,15 @@ main(
> reqval('n', nopts, N_FTYPE);
> if (nftype)
> respec('n', nopts, N_FTYPE);
> - dirftype = atoi(value);
> + c = atoi(value);
> + if (c < 0 || c > 1)
> + illegal(value, "n ftype");
> + if (crcs_enabled) {
> + fprintf(stderr,
> +_("cannot specify both crc and ftype\n"));
> + usage();
> + }
> + dirftype = c;
> nftype = 1;
> break;