Re: [PATCH] Added Restriction on base value

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Aug 12 19:39, Aditya Upadhyay wrote:
> ---
>  newlib/libc/stdlib/strtoimax.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/newlib/libc/stdlib/strtoimax.c b/newlib/libc/stdlib/strtoimax.c
> index 6901612..c3f27df 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;
> -- 
> 2.7.4

Pushed.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAltxNwkACgkQ9TYGna5E
T6BzaA/+P8MZIhLMCfviSJve2wReu9RhkBTFuxyt0t8yrzclXFuxWCq/vA+9Jphh
p0CQp9bVWw1MyL4YvtlZJfZkqYXQ5Cii2Hls3Zrpy/dNmis+ZwcxreSV/ub7VPLf
DkV8Zgb04qfbVVHQxytnAXwLJdrValfczlccB6wu5qVjlgaQqJxQP2mhdLDeXIBU
JuxbdUDNqk0huEFLs6mHuog3Ljecs+psEcbER9dUyC1qtXeO4qLkOSa4T12IX+Bz
t2VCSGoV+0LXjg4ZIZjyh5F3wbUXkIV5vGHgwzsq9t89a6zzcSEiMrWCTR3T6iE4
Q5WBAyF0pzrKtrNLOJF/HS6jcYyS9VuZSAgJ6Gmb9z+jWh5BCbIBsDrr6DZuIOsU
di6DbAQQZuxPLi8z1T36IR3IdN/xRqubwKvPFQww5IjBnQ5PjHUHPTY25fDp+40S
/w27N/3VHdmtVlIE2kL6D81lxby9npJwckSNNQfhetvZHIqGTA63fci9KT9fkAV9
KW1Ou3CvxjaAkRvOGCiCFq0ChGPlhY7VVaOlRyrxEQDEqB0sOax4DrUIUUY2CfVu
A68snww9Dka2b86BKCofK1wrOKoWCU/5jdLQTNhTjEI3Mla/hHydeX+k1T+yrQF8
EExqW8YvuXPoRldEdoNw9PBFZ09FkKTibJeoHEWCVxVAz10lr1Q=
=zlzs
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.