File curl-CVE-2018-16840.patch of Package curl.25399

From c6a379a2088884561ad2dc7c12a15cbf1a300c2f Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Thu, 18 Oct 2018 15:07:15 +0200
Subject: [PATCH] Curl_close: clear data->multi_easy on free to avoid
 use-after-free

Regression from b46cfbc068 (7.59.0)

Reported-by: Brian Carpenter (Geeknik Labs)
---
 lib/url.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/url.c b/lib/url.c
index 0cc7d591a..a6e315fdc 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -329,14 +329,16 @@ CURLcode Curl_close(struct Curl_easy *data)
   if(m)
     /* This handle is still part of a multi handle, take care of this first
        and detach this handle from there. */
     curl_multi_remove_handle(data->multi, data);
 
-  if(data->multi_easy)
+  if(data->multi_easy) {
     /* when curl_easy_perform() is used, it creates its own multi handle to
        use and this is the one */
     curl_multi_cleanup(data->multi_easy);
+    data->multi_easy = NULL;
+  }
 
   /* Destroy the timeout list that is held in the easy handle. It is
      /normally/ done by curl_multi_remove_handle() but this is "just in
      case" */
   Curl_llist_destroy(&data->state.timeoutlist, NULL);
-- 
2.19.1
openSUSE Build Service is sponsored by