... leaving the k->str could lead to buffer over-reads later on. 82/183082/1
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 2 Jul 2018 04:54:24 +0000 (13:54 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Mon, 2 Jul 2018 06:13:04 +0000 (15:13 +0900)
CVE: CVE-2018-1000301
Assisted-by: Max Dymond
Detected by OSS-Fuzz.
Bug: https://curl.haxx.se/docs/adv_2018-b138.html
Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7105

Change-Id: I0bd3b891aef2bf08fdb485d135e695c2eeab86a7

lib/http.c

index 841f6cc0b41616db37fb399e54450d3318af894b..dc10f5fa6cbc5a647b71f4a0756173a8ce4d4370 100644 (file)
@@ -2966,6 +2966,8 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
 {
   CURLcode result;
   struct SingleRequest *k = &data->req;
+  ssize_t onread = *nread;
+  char *ostr = k->str;
 
   /* header line within buffer loop */
   do {
@@ -3030,7 +3032,9 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
         else {
           /* this was all we read so it's all a bad header */
           k->badheader = HEADER_ALLBAD;
-          *nread = (ssize_t)rest_length;
+          *nread = onread;
+          k->str = ostr;
+          return CURLE_OK;
         }
         break;
       }