[PATCH 04/19] mkfs: validate all input values
Eric Sandeen
sandeen at sandeen.net
Wed Apr 6 18:02:17 CDT 2016
On 3/24/16 6:15 AM, jtulak at redhat.com wrote:
> From: Dave Chinner <dchinner at 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
More information about the xfs
mailing list