Re: [PATCH 04/19] mkfs: validate all input values

Eric Sandeen
2016-04-06T23:02:28Z

On 3/24/16 6:15 AM, jtulak@redhat.com wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> CHANGELOG
> o Fix an unsigned < 0 comparison - save getnum result to another variable
> and test it, before converting it to unsigned logagno.

...

> @@ -1468,7 +1485,10 @@ main(
> respec('l', lopts, L_AGNUM);
> if (ldflag)
> conflict('l', lopts, L_AGNUM, L_DEV);
> - logagno = atoi(value);
> + tmp_num = getnum(value, 0, 0, false);
> + if (tmp_num < 0)
> + illegal(value, "l agno");
> + logagno = (xfs_agnumber_t)tmp_num;
> laflag = 1;
> break;
> case L_FILE:

Why not cast to (__int64_t) like other variables do? i.e.

+ logagno = getnum(value, 0, 0, false);
+ if ((__int64_t)logagno < 0)
+ illegal(value, "l agno");

or am I missing something?

Thanks,
-Eric