]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
progress: fix integer overflow check
authorJay Satiro <raysatiro@yahoo.com>
Mon, 28 Apr 2025 17:35:44 +0000 (13:35 -0400)
committerJay Satiro <raysatiro@yahoo.com>
Mon, 28 Apr 2025 18:07:32 +0000 (14:07 -0400)
- Fix logic typo.

Prior to this change the overflow check was reversed, meaning it did
not stop an overflow condition and also if there wasn't an overflow it
erroneously set the total expected transfer size to the maximum value.

Follow-up to 69ce9a7f from earlier today.

Closes https://github.com/curl/curl/pull/17213

lib/progress.c

index f02bfb2c08324fddb3be5abe478e810dbb4cad5b..aa63fed0e598577c226b13f0e566ca588a3841c8 100644 (file)
@@ -548,7 +548,7 @@ static void progress_meter(struct Curl_easy *data)
     ((p->flags & PGRS_DL_SIZE_KNOWN) ? p->dl.total_size : p->dl.cur_size);
 
   /* integer overflow check */
-  if((CURL_OFF_T_MAX - total_expected_size) > dl_size)
+  if((CURL_OFF_T_MAX - total_expected_size) < dl_size)
     total_expected_size = CURL_OFF_T_MAX; /* capped */
   else
     total_expected_size += dl_size;