summaryrefslogtreecommitdiff
path: root/src/tool_cb_prg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool_cb_prg.c')
-rw-r--r--src/tool_cb_prg.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c
index e2ee54225..a18827c8b 100644
--- a/src/tool_cb_prg.c
+++ b/src/tool_cb_prg.c
@@ -125,14 +125,19 @@ int tool_progress_cb(void *clientp,
curl_off_t total;
curl_off_t point;
- /* expected transfer size */
- if((CURL_OFF_T_MAX - bar->initial_size) < (dltotal + ultotal))
+ /* Calculate expected transfer size. initial_size can be less than zero
+ 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;
else
total = dltotal + ultotal + bar->initial_size;
- /* we've come this far */
- if((CURL_OFF_T_MAX - bar->initial_size) < (dlnow + ulnow))
+ /* Calculate the current progress. initial_size can be less than zero 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) < (dlnow + ulnow)))
point = CURL_OFF_T_MAX;
else
point = dlnow + ulnow + bar->initial_size;
@@ -205,7 +210,8 @@ void progressbarinit(struct ProgressData *bar,
if(colp) {
char *endptr;
long num = strtol(colp, &endptr, 10);
- if((endptr != colp) && (endptr == colp + strlen(colp)) && (num > 20))
+ if((endptr != colp) && (endptr == colp + strlen(colp)) && (num > 20) &&
+ (num < 10000))
bar->width = (int)num;
curl_free(colp);
}