Fix: possible NULL dereference in uri_parse_str_urls()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 20 Aug 2018 20:45:09 +0000 (16:45 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Sep 2018 16:15:25 +0000 (12:15 -0400)
The data_url parsing of uri_parse_str_urls assumes that a ctrl
URL was provided to check that both URLs point to the same
destination. A check for 'ctrl_uris != NULL' is added, but this
function needs to be refactored at some point at it is not clear
what its role is (i.e. it's probably doing too much).

Reported-by: Coverity Scan (1378214 Explicit null dereferenced)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/uri.c

index 380e75dd33b4839b144181c35f341a2724ef0f4e..64437272bf3e0a8b51bf76a09e554546f1c61539 100644 (file)
@@ -644,10 +644,12 @@ ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url,
 
                set_default_uri_attr(&data_uris[0], LTTNG_STREAM_DATA);
 
-               ret = compare_destination(&ctrl_uris[0], &data_uris[0]);
-               if (ret != 0) {
-                       ERR("Control and data destination mismatch");
-                       goto error;
+               if (ctrl_uris) {
+                       ret = compare_destination(&ctrl_uris[0], &data_uris[0]);
+                       if (ret != 0) {
+                               ERR("Control and data destination mismatch");
+                               goto error;
+                       }
                }
        }
 
This page took 0.026059 seconds and 4 git commands to generate.