diff options
author | Jim Meyering <jim@meyering.net> | 2005-01-11 16:53:24 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-01-11 16:53:24 +0000 |
commit | c2fed1cc190243e79f4b52c8f6de3f67ec1936e3 (patch) | |
tree | 914fdca725a673b601a8b8bb1557899c4b3fb651 /src | |
parent | 1377220ccf3362dd08832c711ca14a1fe3381697 (diff) | |
download | coreutils-c2fed1cc190243e79f4b52c8f6de3f67ec1936e3.tar.xz |
(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'.
Diffstat (limited to 'src')
-rw-r--r-- | src/unexpand.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/unexpand.c b/src/unexpand.c index 1341e437c..60a3f1d61 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -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; } |