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.11.0-rc4~70 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=451baac3a0cc0da7a73d20a2f1c8f4f133164e5f;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; + } } }