mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-19 12:59:21 +08:00
Return EINVAL for illegal base in strtol
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
575ea861b6
commit
50da85a5da
@ -140,6 +140,11 @@ _strtol_l (struct _reent *rptr, const char *__restrict nptr,
|
||||
register unsigned long cutoff;
|
||||
register int neg = 0, any, cutlim;
|
||||
|
||||
if (base < 0 || base == 1 || base > 36) {
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
@ -193,9 +198,9 @@ _strtol_l (struct _reent *rptr, const char *__restrict nptr,
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) {
|
||||
any = -1;
|
||||
else {
|
||||
} else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
|
Loading…
x
Reference in New Issue
Block a user