]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: restore buffer pointer when bad response-line is parsed
authorDaniel Stenberg <daniel@haxx.se>
Sat, 24 Mar 2018 22:47:41 +0000 (23:47 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 14 May 2018 05:40:31 +0000 (07:40 +0200)
... leaving the k->str could lead to buffer over-reads later on.

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

lib/http.c

index 1a313b4fbec46f1c45671b42d8b9263ad0c53abc..e080ae513c6e3786b880823e7389fa1b61f8a215 100644 (file)
@@ -3014,6 +3014,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 {
@@ -3078,7 +3080,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;
       }