b35f73
From 235f209a0e62edee654be441a50bb0c154edeaa5 Mon Sep 17 00:00:00 2001
b35f73
From: Daniel Stenberg <daniel@haxx.se>
b35f73
Date: Thu, 18 Oct 2018 15:07:15 +0200
b35f73
Subject: [PATCH] Curl_close: clear data->multi_easy on free to avoid
b35f73
 use-after-free
b35f73
b35f73
Regression from b46cfbc068 (7.59.0)
b35f73
CVE-2018-16840
b35f73
Reported-by: Brian Carpenter (Geeknik Labs)
b35f73
b35f73
Bug: https://curl.haxx.se/docs/CVE-2018-16840.html
b35f73
b35f73
Upstream-commit: 81d135d67155c5295b1033679c606165d4e28f3f
b35f73
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b35f73
---
b35f73
 lib/url.c | 4 +++-
b35f73
 1 file changed, 3 insertions(+), 1 deletion(-)
b35f73
b35f73
diff --git a/lib/url.c b/lib/url.c
b35f73
index f159008..dcc1ecc 100644
b35f73
--- a/lib/url.c
b35f73
+++ b/lib/url.c
b35f73
@@ -319,10 +319,12 @@ CURLcode Curl_close(struct Curl_easy *data)
b35f73
        and detach this handle from there. */
b35f73
     curl_multi_remove_handle(data->multi, data);
b35f73
 
b35f73
-  if(data->multi_easy)
b35f73
+  if(data->multi_easy) {
b35f73
     /* when curl_easy_perform() is used, it creates its own multi handle to
b35f73
        use and this is the one */
b35f73
     curl_multi_cleanup(data->multi_easy);
b35f73
+    data->multi_easy = NULL;
b35f73
+  }
b35f73
 
b35f73
   /* Destroy the timeout list that is held in the easy handle. It is
b35f73
      /normally/ done by curl_multi_remove_handle() but this is "just in
b35f73
-- 
b35f73
2.17.2
b35f73