diff options
author | Jim Meyering <jim@meyering.net> | 2003-07-26 09:10:45 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-07-26 09:10:45 +0000 |
commit | cab4bde6e1f2ac125859f605a2e95109c4aa3e47 (patch) | |
tree | 6d5c2780c7755bdbcda196fa93d348522298c466 /src | |
parent | 46baf9f422af2437c97dcab3169ba425d045c6dc (diff) | |
download | coreutils-cab4bde6e1f2ac125859f605a2e95109c4aa3e47.tar.xz |
(parse_tabstops): Detect overflow properly.
Diffstat (limited to 'src')
-rw-r--r-- | src/expand.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/expand.c b/src/expand.c index fcd35429b..8be52b563 100644 --- a/src/expand.c +++ b/src/expand.c @@ -173,10 +173,11 @@ parse_tabstops (char const *stops) num_start = stops; } { + int new_t; + /* Detect overflow. */ - int prev = tabval; - tabval = tabval * 10 + *stops - '0'; - if (tabval < prev) + new_t = 10 * tabval + *stops - '0'; + if (INT_MAX / 10 < tabval || new_t < tabval * 10) { size_t len = strspn (num_start, "0123456789"); char *bad_num = xstrndup (num_start, len); @@ -184,6 +185,7 @@ parse_tabstops (char const *stops) fail = 1; stops = num_start + len - 1; } + tabval = new_t; } } else |