mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
tool_cb_prg: Fix integer overflow in progress bar
Commit 61faa0b420c236480bc9ef6fd52b4ecc1e0f8d17 fixed the progress bar width calculation to avoid integer overflow, but failed to account for the fact that initial_size is initialized to -1 when the file size is retrieved from the remote on an upload, causing another signed integer overflow. Fix by separately checking for this case before the width calculation. Closes #3984 Reported-by: Brian Carpenter (Geeknik Labs) Reviewed-by: Daniel Stenberg <daniel@haxx.se>
This commit is contained in:
parent
deb9462ff2
commit
6df5f35e6a
@ -125,14 +125,19 @@ int tool_progress_cb(void *clientp,
|
|||||||
curl_off_t total;
|
curl_off_t total;
|
||||||
curl_off_t point;
|
curl_off_t point;
|
||||||
|
|
||||||
/* expected transfer size */
|
/* Calculate expected transfer size. initial_size can be less than zero
|
||||||
if((CURL_OFF_T_MAX - bar->initial_size) < (dltotal + ultotal))
|
when indicating that we are expecting to get the filesize from the
|
||||||
|
remote */
|
||||||
|
if(bar->initial_size < 0 ||
|
||||||
|
((CURL_OFF_T_MAX - bar->initial_size) < (dltotal + ultotal)))
|
||||||
total = CURL_OFF_T_MAX;
|
total = CURL_OFF_T_MAX;
|
||||||
else
|
else
|
||||||
total = dltotal + ultotal + bar->initial_size;
|
total = dltotal + ultotal + bar->initial_size;
|
||||||
|
|
||||||
/* we've come this far */
|
/* Calculate the current progress. initial_size can be less than zero when
|
||||||
if((CURL_OFF_T_MAX - bar->initial_size) < (dlnow + ulnow))
|
indicating that we are expecting to get the filesize from the remote */
|
||||||
|
if(bar->initial_size < 0 ||
|
||||||
|
((CURL_OFF_T_MAX - bar->initial_size) < (dlnow + ulnow)))
|
||||||
point = CURL_OFF_T_MAX;
|
point = CURL_OFF_T_MAX;
|
||||||
else
|
else
|
||||||
point = dlnow + ulnow + bar->initial_size;
|
point = dlnow + ulnow + bar->initial_size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user