mirror of
https://git.FreeBSD.org/src.git
synced 2025-02-06 18:29:47 +00:00
sh: Reject integer overflow in number and is_number.
This commit is contained in:
parent
1c9c6ea481
commit
d53f7f64f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=270102
@ -82,9 +82,17 @@ number(const char *s)
|
|||||||
int
|
int
|
||||||
is_number(const char *p)
|
is_number(const char *p)
|
||||||
{
|
{
|
||||||
do {
|
const char *q;
|
||||||
if (! is_digit(*p))
|
|
||||||
|
if (*p == '\0')
|
||||||
|
return 0;
|
||||||
|
while (*p == '0')
|
||||||
|
p++;
|
||||||
|
for (q = p; *q != '\0'; q++)
|
||||||
|
if (! is_digit(*q))
|
||||||
return 0;
|
return 0;
|
||||||
} while (*++p != '\0');
|
if (q - p > 10 ||
|
||||||
|
(q - p == 10 && memcmp(p, "2147483647", 10) > 0))
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user