mirror of
https://github.com/curl/curl.git
synced 2026-08-24 11:43:38 +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
|
|
@ -590,7 +590,11 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
{
|
||||
/* We support G, M, K too */
|
||||
char *unit;
|
||||
curl_off_t value = curlx_strtoofft(nextarg, &unit, 0);
|
||||
curl_off_t value;
|
||||
if(curlx_strtoofft(nextarg, &unit, 0, &value)) {
|
||||
warnf(global, "unsupported rate\n");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
|
||||
if(!*unit)
|
||||
unit = (char *)"b";
|
||||
|
|
@ -1843,10 +1847,13 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
if(ISDIGIT(*nextarg) && !strchr(nextarg, '-')) {
|
||||
char buffer[32];
|
||||
curl_off_t off;
|
||||
if(curlx_strtoofft(nextarg, NULL, 10, &off)) {
|
||||
warnf(global, "unsupported range point\n");
|
||||
return PARAM_BAD_USE;
|
||||
}
|
||||
warnf(global,
|
||||
"A specified range MUST include at least one dash (-). "
|
||||
"Appending one for you!\n");
|
||||
off = curlx_strtoofft(nextarg, NULL, 10);
|
||||
snprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", off);
|
||||
Curl_safefree(config->range);
|
||||
config->range = strdup(buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue