Fix: relayd: Dereference before null check
[lttng-tools.git] / src / common / relayd / relayd.c
index 49997015e3f9cb73f7fa63fa99c703dbb67a095b..12f70f7e0bf8ad39dbcb5489b84fa953e3626bda 100644 (file)
@@ -161,7 +161,7 @@ static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock,
        /* The three names are sent with a '\0' delimiter between them. */
        session_name_len = strlen(session_name) + 1;
        hostname_len = strlen(hostname) + 1;
-       base_path_len = base_path ? strlen(base_path) + 1 : 0;
+       base_path_len = strlen(base_path) + 1;
 
        msg_length = sizeof(*msg) + session_name_len + hostname_len + base_path_len;
        msg = zmalloc(msg_length);
@@ -191,7 +191,7 @@ static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock,
                goto error;
        }
        dst += hostname_len;
-       if (base_path && lttng_strncpy(dst, base_path, base_path_len)) {
+       if (lttng_strncpy(dst, base_path, base_path_len)) {
                ret = -1;
                goto error;
        }
@@ -1480,6 +1480,8 @@ int relayd_trace_chunk_exists(struct lttcomm_relayd_sock *sock,
 
        if (!relayd_supports_chunks(sock)) {
                DBG("Refusing to check for trace chunk existence: relayd does not support chunks");
+               /* The chunk will never exist */
+               *chunk_exists = false;
                goto end;
        }
 
This page took 0.027526 seconds and 5 git commands to generate.