107-CVE-2017-1000257.patch 902 B

12345678910111213141516171819202122232425262728
  1. From 13c9a9ded3ae744a1e11cbc14e9146d9fa427040 Mon Sep 17 00:00:00 2001
  2. From: Daniel Stenberg <daniel@haxx.se>
  3. Date: Sat, 7 Oct 2017 00:11:31 +0200
  4. Subject: [PATCH] imap: if a FETCH response has no size, don't call write
  5. callback
  6. CVE-2017-1000257
  7. Reported-by: Brian Carpenter and 0xd34db347
  8. Also detected by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3586
  9. ---
  10. lib/imap.c | 5 +++++
  11. 1 file changed, 5 insertions(+)
  12. --- a/lib/imap.c
  13. +++ b/lib/imap.c
  14. @@ -1140,6 +1140,11 @@ static CURLcode imap_state_fetch_resp(st
  15. /* The conversion from curl_off_t to size_t is always fine here */
  16. chunk = (size_t)size;
  17. + if(!chunk) {
  18. + /* no size, we're done with the data */
  19. + state(conn, IMAP_STOP);
  20. + return CURLE_OK;
  21. + }
  22. result = Curl_client_write(conn, CLIENTWRITE_BODY, pp->cache, chunk);
  23. if(result)
  24. return result;