aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-03-24 23:47:41 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-05-14 07:40:31 +0200
commit8c7b3737d29ed5c0575bf592063de8a51450812d (patch)
tree6b5b9129617c308bee42ae6ea34c85b8ebafd562 /lib
parent1b55d270ad3d4473b2fd46481478275e47c60eaf (diff)
http: restore buffer pointer when bad response-line is parsed
... 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
Diffstat (limited to 'lib')
-rw-r--r--lib/http.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/http.c b/lib/http.c
index 1a313b4fb..e080ae513 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -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;
}