Blame SOURCES/0001-python-pycurl-7.43.0.2-static-analysis.patch

808084
From 047bd00ee53a722eaf46e58e330888cf628d5a7c Mon Sep 17 00:00:00 2001
808084
From: Kamil Dudka <kdudka@redhat.com>
808084
Date: Mon, 14 Jan 2019 16:54:19 +0100
808084
Subject: [PATCH 1/2] do_curl_setopt_httppost: do not use uninitialized stack
808084
 variable
808084
808084
Detected by Coverity Analysis and Clang:
808084
808084
Error: UNINIT (CWE-457):
808084
pycurl-7.43.0.2/src/easyopt.c:493: var_decl: Declaring variable "res" without initializer.
808084
pycurl-7.43.0.2/src/easyopt.c:524: uninit_use_in_call: Using uninitialized value "(int)res" when calling "create_and_set_error_object".
808084
522|               if (PyText_AsStringAndSize(httppost_option, &cstr, &clen, &cencoded_obj)) {
808084
523|                   PyText_EncodedDecref(nencoded_obj);
808084
524|->                 CURLERROR_SET_RETVAL();
808084
525|                   goto error;
808084
526|               }
808084
808084
Error: CLANG_WARNING:
808084
pycurl-7.43.0.2/src/easyopt.c:524:17: warning: 2nd function call argument is an uninitialized value
808084
pycurl-7.43.0.2/src/pycurl.h:286:5: note: expanded from macro 'CURLERROR_SET_RETVAL'
808084
pycurl-7.43.0.2/src/easyopt.c:493:5: note: 'res' declared without an initial value
808084
pycurl-7.43.0.2/src/easyopt.c:496:9: note: Assuming 'len' is not equal to 0
808084
pycurl-7.43.0.2/src/easyopt.c:496:5: note: Taking false branch
808084
pycurl-7.43.0.2/src/easyopt.c:499:17: note: Assuming 'i' is < 'len'
808084
pycurl-7.43.0.2/src/easyopt.c:499:5: note: Loop condition is true.  Entering loop body
808084
pycurl-7.43.0.2/src/easyopt.c:505:13: note: Assuming 'which_httppost_item' is not equal to 0
808084
pycurl-7.43.0.2/src/easyopt.c:505:9: note: Taking false branch
808084
pycurl-7.43.0.2/src/easyopt.c:509:13: note: Assuming the condition is false
808084
pycurl-7.43.0.2/src/easyopt.c:509:9: note: Taking false branch
808084
pycurl-7.43.0.2/src/easyopt.c:513:13: note: Assuming the condition is false
808084
pycurl-7.43.0.2/src/easyopt.c:513:9: note: Taking false branch
808084
pycurl-7.43.0.2/src/easyopt.c:519:13: note: Assuming the condition is true
808084
pycurl-7.43.0.2/src/easyopt.c:519:9: note: Taking true branch
808084
pycurl-7.43.0.2/src/easyopt.c:522:17: note: Assuming the condition is true
808084
pycurl-7.43.0.2/src/easyopt.c:522:13: note: Taking true branch
808084
pycurl-7.43.0.2/src/easyopt.c:524:17: note: 2nd function call argument is an uninitialized value
808084
pycurl-7.43.0.2/src/pycurl.h:286:5: note: expanded from macro 'CURLERROR_SET_RETVAL'
808084
---
808084
 src/easyopt.c | 2 +-
808084
 1 file changed, 1 insertion(+), 1 deletion(-)
808084
808084
diff --git a/src/easyopt.c b/src/easyopt.c
808084
index 015fa93..471400c 100644
808084
--- a/src/easyopt.c
808084
+++ b/src/easyopt.c
808084
@@ -521,7 +521,7 @@ do_curl_setopt_httppost(CurlObject *self, int option, int which, PyObject *obj)
808084
 
808084
             if (PyText_AsStringAndSize(httppost_option, &cstr, &clen, &cencoded_obj)) {
808084
                 PyText_EncodedDecref(nencoded_obj);
808084
-                CURLERROR_SET_RETVAL();
808084
+                create_and_set_error_object(self, CURLE_BAD_FUNCTION_ARGUMENT);
808084
                 goto error;
808084
             }
808084
             /* INFO: curl_formadd() internally does memdup() the data, so
808084
-- 
808084
2.17.2
808084
808084
808084
From 6f0f7896412c107c390f4967dcdf94fd14d52047 Mon Sep 17 00:00:00 2001
808084
From: Kamil Dudka <kdudka@redhat.com>
808084
Date: Mon, 14 Jan 2019 16:57:14 +0100
808084
Subject: [PATCH 2/2] do_multi_add_handle: execute clean-up code before return
808084
808084
Detected by Coverity Analysis:
808084
808084
Error: UNREACHABLE (CWE-561):
808084
pycurl-7.43.0.2/src/multi.c:631: unreachable: This code cannot be reached: "PyDict_DelItem(self->easy_o...".
808084
629|       if (res != CURLM_OK) {
808084
630|           CURLERROR_MSG("curl_multi_add_handle() failed due to internal errors");
808084
631|->         PyDict_DelItem(self->easy_object_dict, (PyObject *) obj);
808084
632|       }
808084
633|       obj->multi_stack = self;
808084
---
808084
 src/multi.c | 2 +-
808084
 1 file changed, 1 insertion(+), 1 deletion(-)
808084
808084
diff --git a/src/multi.c b/src/multi.c
808084
index 7ecedbf..3407423 100644
808084
--- a/src/multi.c
808084
+++ b/src/multi.c
808084
@@ -627,8 +627,8 @@ do_multi_add_handle(CurlMultiObject *self, PyObject *args)
808084
     assert(obj->multi_stack == NULL);
808084
     res = curl_multi_add_handle(self->multi_handle, obj->handle);
808084
     if (res != CURLM_OK) {
808084
-        CURLERROR_MSG("curl_multi_add_handle() failed due to internal errors");
808084
         PyDict_DelItem(self->easy_object_dict, (PyObject *) obj);
808084
+        CURLERROR_MSG("curl_multi_add_handle() failed due to internal errors");
808084
     }
808084
     obj->multi_stack = self;
808084
     Py_INCREF(self);
808084
-- 
808084
2.17.2
808084