(main): Check for overflow in tabstop values

specified via the obsolete form.  E.g., now this command fails:
_POSIX2_VERSION=1 ./unexpand -$(echo '2^64+1'|bc)
Before it would act like `_POSIX2_VERSION=1 ./unexpand -1'.
This commit is contained in:
Jim Meyering committed 2005-01-11 16:53:24 +00:00
1 parent 1377220ccf
commit c2fed1cc19
1 file changed
+6 -1
+6 -1
View File
@@ -518,7 +518,12 @@ main (int argc, char **argv)
tabval = 0;
have_tabval = true;
}
tabval = tabval * 10 + c - '0';
{
uintmax_t new_t = tabval * 10 + c - '0';
if (UINTMAX_MAX / 10 < tabval || new_t < tabval * 10)
error (EXIT_FAILURE, 0, _("tab stop value is too large"));
tabval = new_t;
}
obsolete_tablist = true;
break;
}