summaryrefslogtreecommitdiff
path: root/src/expand.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-07-26 09:10:45 +0000
committerJim Meyering <jim@meyering.net>2003-07-26 09:10:45 +0000
commitcab4bde6e1f2ac125859f605a2e95109c4aa3e47 (patch)
tree6d5c2780c7755bdbcda196fa93d348522298c466 /src/expand.c
parent46baf9f422af2437c97dcab3169ba425d045c6dc (diff)
downloadcoreutils-cab4bde6e1f2ac125859f605a2e95109c4aa3e47.tar.xz
(parse_tabstops): Detect overflow properly.
Diffstat (limited to 'src/expand.c')
-rw-r--r--src/expand.c8
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