projects
/
platform
/
upstream
/
coreutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
46baf9f
)
(parse_tabstops): Detect overflow properly.
author
Jim Meyering
<jim@meyering.net>
Sat, 26 Jul 2003 09:10:45 +0000
(09:10 +0000)
committer
Jim Meyering
<jim@meyering.net>
Sat, 26 Jul 2003 09:10:45 +0000
(09:10 +0000)
src/expand.c
patch
|
blob
|
history
diff --git
a/src/expand.c
b/src/expand.c
index fcd35429bb63ac186260b8b82e934f7b2de1235f..8be52b5631dd0ddf8d0cf52dd1294ace45585116 100644
(file)
--- 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