From: Jérémie Galarneau Date: Tue, 10 Sep 2019 23:30:33 +0000 (-0400) Subject: Fix: session may be NULL in relay_create_session error path X-Git-Tag: v2.12.0-rc1~417 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8d382dd4d4e95ea6ff88d6bd9f8a8fc85970ee3b;p=lttng-tools.git Fix: session may be NULL in relay_create_session error path A reply is sent in response to a session's creation even if it failed to be created. In those cases, session is null and its output_path should not be accessed. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 8e67f7664..2ffa75078 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -1157,21 +1157,24 @@ send_reply: } } else { const uint32_t output_path_length = - strlen(session->output_path) + 1; + session ? strlen(session->output_path) + 1 : 0; reply.output_path_length = htobe32(output_path_length); - ret = lttng_dynamic_buffer_append(&reply_payload, &reply, - sizeof(reply)); + ret = lttng_dynamic_buffer_append( + &reply_payload, &reply, sizeof(reply)); if (ret) { ERR("Failed to append \"create session\" command reply header to payload buffer"); goto end; } - ret = lttng_dynamic_buffer_append(&reply_payload, - session->output_path, output_path_length); - if (ret) { - ERR("Failed to append \"create session\" command reply path to payload buffer"); - goto end; + if (output_path_length) { + ret = lttng_dynamic_buffer_append(&reply_payload, + session->output_path, + output_path_length); + if (ret) { + ERR("Failed to append \"create session\" command reply path to payload buffer"); + goto end; + } } }