114-CVE-2018-1000301.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 8c7b3737d29ed5c0575bf592063de8a51450812d Mon Sep 17 00:00:00 2001
  2. From: Daniel Stenberg <daniel@haxx.se>
  3. Date: Sat, 24 Mar 2018 23:47:41 +0100
  4. Subject: [PATCH] http: restore buffer pointer when bad response-line is parsed
  5. ... leaving the k->str could lead to buffer over-reads later on.
  6. CVE: CVE-2018-1000301
  7. Assisted-by: Max Dymond
  8. Detected by OSS-Fuzz.
  9. Bug: https://curl.haxx.se/docs/adv_2018-b138.html
  10. Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7105
  11. ---
  12. lib/http.c | 6 +++++-
  13. 1 file changed, 5 insertions(+), 1 deletion(-)
  14. --- a/lib/http.c
  15. +++ b/lib/http.c
  16. @@ -2924,6 +2924,8 @@ CURLcode Curl_http_readwrite_headers(str
  17. {
  18. CURLcode result;
  19. struct SingleRequest *k = &data->req;
  20. + ssize_t onread = *nread;
  21. + char *ostr = k->str;
  22. /* header line within buffer loop */
  23. do {
  24. @@ -2988,7 +2990,9 @@ CURLcode Curl_http_readwrite_headers(str
  25. else {
  26. /* this was all we read so it's all a bad header */
  27. k->badheader = HEADER_ALLBAD;
  28. - *nread = (ssize_t)rest_length;
  29. + *nread = onread;
  30. + k->str = ostr;
  31. + return CURLE_OK;
  32. }
  33. break;
  34. }