]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
imap: make sure Curl_pgrsSetDownloadSize() does not overflow
authorDaniel Stenberg <daniel@haxx.se>
Sun, 30 Nov 2025 22:35:25 +0000 (23:35 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 1 Dec 2025 07:37:23 +0000 (08:37 +0100)
Follow-up to c1e3a760b. The previous update missed an addition that also
can wrap and cause confusion. Fixing this by calling
Curl_pgrsSetDownloadSize() after the overflow check.

Reported-by: Deniz Parlak
Closes #19774

lib/imap.c

index d093e46d33abb5fcb0207bb46782a2990e58905e..9d58bec4ec81e64bb7b99cabc5c2d86ba82a9c57 100644 (file)
@@ -1214,8 +1214,6 @@ static CURLcode imap_state_listsearch_resp(struct Curl_easy *data,
 
         /* This is a literal response, setup to receive the body data */
         infof(data, "Found %" FMT_OFF_T " bytes to download", size);
-        /* Progress size includes both header line and literal body */
-        Curl_pgrsSetDownloadSize(data, size + len);
 
         /* First write the header line */
         result = Curl_client_write(data, CLIENTWRITE_BODY, line, len);
@@ -1268,6 +1266,9 @@ static CURLcode imap_state_listsearch_resp(struct Curl_easy *data,
         else
           size += len;
 
+        /* Progress size includes both header line and literal body */
+        Curl_pgrsSetDownloadSize(data, size);
+
         if(data->req.bytecount == size)
           /* All data already transferred (header + literal body) */
           Curl_xfer_setup_nop(data);