lib: let the max filesize option stop too big transfers too

Previously it would only stop them from getting started if the size is
known to be too big then.

Update the libcurl and curl docs accordingly.

Fixes #11810
Reported-by: Elliot Killick
Assisted-by: Jay Satiro
Closes #11820
This commit is contained in:
Daniel Stenberg 2023-09-23 11:20:00 +02:00
parent 38029101e2
commit 914e49b9b7
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
13 changed files with 55 additions and 15 deletions

View file

@ -317,9 +317,16 @@ timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
/*
* Set the number of downloaded bytes so far.
*/
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
CURLcode Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
{
if(data->set.max_filesize && (size > data->set.max_filesize)) {
failf(data, "Exceeded the maximum allowed file size "
"(%" CURL_FORMAT_CURL_OFF_T ")",
data->set.max_filesize);
return CURLE_FILESIZE_EXCEEDED;
}
data->progress.downloaded = size;
return CURLE_OK;
}
/*