Added Restriction on base value

This commit is contained in:
Aditya Upadhyay 2018-08-12 19:39:52 +05:30 committed by Corinna Vinschen
parent 423fc83dfd
commit a9a4554723
1 changed files with 4 additions and 0 deletions

View File

@ -91,6 +91,9 @@ _strtoimax_l(struct _reent *rptr, const char * __restrict nptr,
if (base == 0) if (base == 0)
base = c == '0' ? 8 : 10; base = c == '0' ? 8 : 10;
if (base < 2 || base > 36)
goto noconv;
/* /*
* Compute the cutoff value between legal numbers and illegal * Compute the cutoff value between legal numbers and illegal
* numbers. That is the largest legal value, divided by the * numbers. That is the largest legal value, divided by the
@ -135,6 +138,7 @@ _strtoimax_l(struct _reent *rptr, const char * __restrict nptr,
acc = neg ? INTMAX_MIN : INTMAX_MAX; acc = neg ? INTMAX_MIN : INTMAX_MAX;
rptr->_errno = ERANGE; rptr->_errno = ERANGE;
} else if (!any) { } else if (!any) {
noconv:
rptr->_errno = EINVAL; rptr->_errno = EINVAL;
} else if (neg) } else if (neg)
acc = -acc; acc = -acc;