From 70bc2efdc665e3a2e4c6eb000c5879960fb2ee8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 20 Aug 2018 16:45:09 -0400 Subject: [PATCH] Fix: possible NULL dereference in uri_parse_str_urls() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/common/uri.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/uri.c b/src/common/uri.c index c6d76bf66..7fe4dd3b3 100644 --- a/src/common/uri.c +++ b/src/common/uri.c @@ -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; + } } } -- 2.34.1