File curl-CVE-2018-1000301.patch of Package curl.12450

From 8268099b7146450fe508231842bb1549f0e3ccf1 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Sat, 24 Mar 2018 23:47:41 +0100
Subject: [PATCH] http: restore buffer pointer when bad response-line is parsed

... leaving the k->str could lead to buffer over-reads later on.

Assisted-by: Max Dymond

Detected by OSS-Fuzz.
Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7105
---
 lib/http.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/http.c b/lib/http.c
index 1a313b4fb..e080ae513 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -3012,10 +3012,12 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
                                        ssize_t *nread,
                                        bool *stop_reading)
 {
   CURLcode result;
   struct SingleRequest *k = &data->req;
+  ssize_t onread = *nread;
+  char *ostr = k->str;
 
   /* header line within buffer loop */
   do {
     size_t rest_length;
     size_t full_length;
@@ -3076,11 +3078,13 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
           /* since there's more, this is a partial bad header */
           k->badheader = HEADER_PARTHEADER;
         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;
       }
     }
 
-- 
2.17.0
openSUSE Build Service is sponsored by