mirror of
https://github.com/curl/curl.git
synced 2026-08-25 05:13:31 +03:00
Curl_pgrsTime - return new time to avoid timeout integer overflow
Setting a timeout to INT_MAX could cause an immediate error to get returned as timeout because of an overflow when different values of 'now' were used. This is primarily fixed by having Curl_pgrsTime() return the "now" when TIMER_STARTSINGLE is set so that the parent function will continue using that time. Reported-by: Ionuț-Francisc Oancea Fixes #5583 Closes #5847
This commit is contained in:
parent
68a5132474
commit
a2c85bb8e4
4 changed files with 27 additions and 23 deletions
|
|
@ -164,9 +164,13 @@ void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
|
|||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Curl_pgrsTime(). Store the current time at the given label. This fetches a
|
||||
* fresh "now" and returns it.
|
||||
*
|
||||
* @unittest: 1399
|
||||
*/
|
||||
void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
|
||||
struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer)
|
||||
{
|
||||
struct curltime now = Curl_now();
|
||||
timediff_t *delta = NULL;
|
||||
|
|
@ -209,7 +213,7 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
|
|||
* changing the t_starttransfer time.
|
||||
*/
|
||||
if(data->progress.is_t_startransfer_set) {
|
||||
return;
|
||||
return now;
|
||||
}
|
||||
else {
|
||||
data->progress.is_t_startransfer_set = true;
|
||||
|
|
@ -228,6 +232,7 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
|
|||
us = 1; /* make sure at least one microsecond passed */
|
||||
*delta += us;
|
||||
}
|
||||
return now;
|
||||
}
|
||||
|
||||
void Curl_pgrsStartNow(struct Curl_easy *data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue