mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:53:34 +03:00
strtoofft: reduce integer overflow risks globally
... make sure we bail out on overflows. Reported-by: Brian Carpenter Closes #1758
This commit is contained in:
parent
b53b4e4424
commit
ff50fe0348
13 changed files with 196 additions and 131 deletions
|
|
@ -400,9 +400,13 @@ ParameterError str2offset(curl_off_t *val, const char *str)
|
|||
return PARAM_NEGATIVE_NUMERIC;
|
||||
|
||||
#if(CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
|
||||
*val = curlx_strtoofft(str, &endptr, 0);
|
||||
if((*val == CURL_OFF_T_MAX || *val == CURL_OFF_T_MIN) && (errno == ERANGE))
|
||||
return PARAM_NUMBER_TOO_LARGE;
|
||||
{
|
||||
CURLofft offt = curlx_strtoofft(str, &endptr, 0, val);
|
||||
if(CURL_OFFT_FLOW == offt)
|
||||
return PARAM_NUMBER_TOO_LARGE;
|
||||
else if(CURL_OFFT_INVAL == offt)
|
||||
return PARAM_BAD_NUMERIC;
|
||||
}
|
||||
#else
|
||||
errno = 0;
|
||||
*val = strtol(str, &endptr, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue