Blame SOURCES/0001-curl-7.76.1-resource-leaks.patch

b97401
From 2281afef6757ed66c9e8a9a737aa91cb9e2950ef Mon Sep 17 00:00:00 2001
b97401
From: Kamil Dudka <kdudka@redhat.com>
b97401
Date: Fri, 30 Apr 2021 18:14:45 +0200
b97401
Subject: [PATCH 1/2] http2: fix resource leaks in set_transfer_url()
b97401
b97401
... detected by Coverity:
b97401
b97401
Error: RESOURCE_LEAK (CWE-772):
b97401
lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()".
b97401
lib/http2.c:486: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:488: leaked_storage: Variable "u" going out of scope leaks the storage it points to.
b97401
b97401
Error: RESOURCE_LEAK (CWE-772):
b97401
lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()".
b97401
lib/http2.c:493: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:495: leaked_storage: Variable "u" going out of scope leaks the storage it points to.
b97401
b97401
Error: RESOURCE_LEAK (CWE-772):
b97401
lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()".
b97401
lib/http2.c:500: noescape: Resource "u" is not freed or pointed-to in "curl_url_set". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:502: leaked_storage: Variable "u" going out of scope leaks the storage it points to.
b97401
b97401
Error: RESOURCE_LEAK (CWE-772):
b97401
lib/http2.c:480: alloc_fn: Storage is returned from allocation function "curl_url". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:480: var_assign: Assigning: "u" = storage returned from "curl_url()".
b97401
lib/http2.c:505: noescape: Resource "u" is not freed or pointed-to in "curl_url_get". [Note: The source code implementation of the function has been overridden by a builtin model.]
b97401
lib/http2.c:507: leaked_storage: Variable "u" going out of scope leaks the storage it points to.
b97401
b97401
Closes #6986
b97401
b97401
Upstream-commit: 31931704707324af4b4edb24cc877829f7e9949e
b97401
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b97401
---
b97401
 lib/http2.c | 24 +++++++++++++++++-------
b97401
 1 file changed, 17 insertions(+), 7 deletions(-)
b97401
b97401
diff --git a/lib/http2.c b/lib/http2.c
b97401
index ce9a0d3..d5ba89b 100644
b97401
--- a/lib/http2.c
b97401
+++ b/lib/http2.c
b97401
@@ -500,32 +500,42 @@ static int set_transfer_url(struct Curl_easy *data,
b97401
   CURLU *u = curl_url();
b97401
   CURLUcode uc;
b97401
   char *url;
b97401
+  int rc = 0;
b97401
 
b97401
   v = curl_pushheader_byname(hp, ":scheme");
b97401
   if(v) {
b97401
     uc = curl_url_set(u, CURLUPART_SCHEME, v, 0);
b97401
-    if(uc)
b97401
-      return 1;
b97401
+    if(uc) {
b97401
+      rc = 1;
b97401
+      goto fail;
b97401
+    }
b97401
   }
b97401
 
b97401
   v = curl_pushheader_byname(hp, ":authority");
b97401
   if(v) {
b97401
     uc = curl_url_set(u, CURLUPART_HOST, v, 0);
b97401
-    if(uc)
b97401
-      return 2;
b97401
+    if(uc) {
b97401
+      rc = 2;
b97401
+      goto fail;
b97401
+    }
b97401
   }
b97401
 
b97401
   v = curl_pushheader_byname(hp, ":path");
b97401
   if(v) {
b97401
     uc = curl_url_set(u, CURLUPART_PATH, v, 0);
b97401
-    if(uc)
b97401
-      return 3;
b97401
+    if(uc) {
b97401
+      rc = 3;
b97401
+      goto fail;
b97401
+    }
b97401
   }
b97401
 
b97401
   uc = curl_url_get(u, CURLUPART_URL, &url, 0);
b97401
   if(uc)
b97401
-    return 4;
b97401
+    rc = 4;
b97401
+  fail:
b97401
   curl_url_cleanup(u);
b97401
+  if(rc)
b97401
+    return rc;
b97401
 
b97401
   if(data->state.url_alloc)
b97401
     free(data->state.url);
b97401
-- 
b97401
2.30.2
b97401
b97401
b97401
From 92ad72983f8462be1d5a5228672657ddf4d7ed72 Mon Sep 17 00:00:00 2001
b97401
From: Kamil Dudka <kdudka@redhat.com>
b97401
Date: Fri, 30 Apr 2021 18:18:02 +0200
b97401
Subject: [PATCH 2/2] http2: fix a resource leak in push_promise()
b97401
b97401
... detected by Coverity:
b97401
b97401
Error: RESOURCE_LEAK (CWE-772):
b97401
lib/http2.c:532: alloc_fn: Storage is returned from allocation function "duphandle".
b97401
lib/http2.c:532: var_assign: Assigning: "newhandle" = storage returned from "duphandle(data)".
b97401
lib/http2.c:552: noescape: Resource "newhandle" is not freed or pointed-to in "set_transfer_url".
b97401
lib/http2.c:555: leaked_storage: Variable "newhandle" going out of scope leaks the storage it points to.
b97401
b97401
Closes #6986
b97401
b97401
Upstream-commit: 3a6058cb976981ec1db870f9657c73c9a1162822
b97401
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
b97401
---
b97401
 lib/http2.c | 1 +
b97401
 1 file changed, 1 insertion(+)
b97401
b97401
diff --git a/lib/http2.c b/lib/http2.c
b97401
index d5ba89b..d0f69ea 100644
b97401
--- a/lib/http2.c
b97401
+++ b/lib/http2.c
b97401
@@ -581,6 +581,7 @@ static int push_promise(struct Curl_easy *data,
b97401
 
b97401
     rv = set_transfer_url(newhandle, &heads);
b97401
     if(rv) {
b97401
+      (void)Curl_close(&newhandle);
b97401
       rv = CURL_PUSH_DENY;
b97401
       goto fail;
b97401
     }
b97401
-- 
b97401
2.30.2
b97401