diff options
author | Aditya Upadhyay <aadit0402@gmail.com> | 2018-08-12 19:39:52 +0530 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2018-08-13 09:42:21 +0200 |
commit | a9a455472343c04f28661af373b4543268342a25 (patch) | |
tree | 8e9521e57069b4aa10b65131d0ac456646231f29 | |
parent | 423fc83dfd072ab11fadd8cd50b4189c2603670f (diff) | |
download | cygnal-a9a455472343c04f28661af373b4543268342a25.tar.gz cygnal-a9a455472343c04f28661af373b4543268342a25.tar.bz2 cygnal-a9a455472343c04f28661af373b4543268342a25.zip |
Added Restriction on base value
-rw-r--r-- | newlib/libc/stdlib/strtoimax.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/newlib/libc/stdlib/strtoimax.c b/newlib/libc/stdlib/strtoimax.c index 6901612c3..c3f27df2e 100644 --- a/newlib/libc/stdlib/strtoimax.c +++ b/newlib/libc/stdlib/strtoimax.c @@ -91,6 +91,9 @@ _strtoimax_l(struct _reent *rptr, const char * __restrict nptr, if (base == 0) base = c == '0' ? 8 : 10; + if (base < 2 || base > 36) + goto noconv; + /* * Compute the cutoff value between legal numbers and illegal * 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; rptr->_errno = ERANGE; } else if (!any) { +noconv: rptr->_errno = EINVAL; } else if (neg) acc = -acc; |