diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-08-24 11:07:59 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-08-24 11:07:59 +0200 |
commit | 863095f2bcf25d2b0243ad5c67735c04deff4241 (patch) | |
tree | 79a510285513d9eb5fa0ad376b31da5bbe86c6f4 /lib/progress.c | |
parent | 98c94596f5928840177b6bd3c7b0f0dd03a431af (diff) | |
download | curl-bagder/timeout-overflow.tar.gz |
Curl_pgrsTime - return new time to avoid timeout integer overflowbagder/timeout-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
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) |