diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-08-24 11:07:59 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-08-28 14:16:41 +0200 |
commit | a2c85bb8e4ba9fa94b88c7592766763e30379ed2 (patch) | |
tree | 1d13ea2d5984bbe625a1cdc33b994bfc00e6815d /lib/progress.c | |
parent | 68a51324740945f1da9758bc1d26bbe4835bd847 (diff) | |
download | curl-a2c85bb8e4ba9fa94b88c7592766763e30379ed2.tar.gz |
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
Diffstat (limited to 'lib/progress.c')
-rw-r--r-- | lib/progress.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/progress.c b/lib/progress.c index 895138448..eced74c9f 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -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) |