diff options
author | Jim Meyering <jim@meyering.net> | 2005-01-11 16:54:02 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2005-01-11 16:54:02 +0000 |
commit | c8756077c3981f77b5cb1c24b98568fd74d4a310 (patch) | |
tree | 7d147b76a36d2c02da047e57a7b5ee8e85f961a3 /src | |
parent | c2fed1cc190243e79f4b52c8f6de3f67ec1936e3 (diff) | |
download | coreutils-c8756077c3981f77b5cb1c24b98568fd74d4a310.tar.xz |
(main): Check for overflow in tabstop values
specified via the obsolete form. E.g., now this command fails:
_POSIX2_VERSION=1 ./expand -$(echo '2^64+1'|bc)
Before it would act like `_POSIX2_VERSION=1 ./expand -1'.
Diffstat (limited to 'src')
-rw-r--r-- | src/expand.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/expand.c b/src/expand.c index e3584601a..5ea16c07e 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1,5 +1,5 @@ /* expand - convert tabs to spaces - Copyright (C) 89, 91, 1995-2004 Free Software Foundation, Inc. + Copyright (C) 89, 91, 1995-2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -420,7 +420,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; } |