]> granicus.if.org Git - curl/commitdiff
imap: if a FETCH response has no size, don't call write callback
authorDaniel Stenberg <daniel@haxx.se>
Fri, 6 Oct 2017 22:11:31 +0000 (00:11 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 22 Oct 2017 14:02:43 +0000 (16:02 +0200)
CVE-2017-1000257

Reported-by: Brian Carpenter and 0xd34db347
Also detected by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3586

lib/imap.c

index 954d18f378643a406e33382d26839de2ff9d8769..baa31a2f8ca48c58a46a5cf6ae450c5159b6c36a 100644 (file)
@@ -1126,6 +1126,11 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
         /* The conversion from curl_off_t to size_t is always fine here */
         chunk = (size_t)size;
 
+      if(!chunk) {
+        /* no size, we're done with the data */
+        state(conn, IMAP_STOP);
+        return CURLE_OK;
+      }
       result = Curl_client_write(conn, CLIENTWRITE_BODY, pp->cache, chunk);
       if(result)
         return result;