From dba13f1d5dffdd2ecaa14ba8ff88c27805153016 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 28 Feb 2018 16:32:26 -0500 Subject: [PATCH] Fix: fail on truncation of kernel channel path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/kernel-consumer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 160c19f59..74c4b3023 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -52,6 +52,13 @@ static char *create_channel_path(struct consumer_output *consumer, if (ret < 0) { PERROR("snprintf kernel channel path"); goto error; + } else if (ret >= sizeof(tmp_path)) { + ERR("Kernel channel path exceeds the maximal allowed length of of %zu bytes (%i bytes required) with path \"%s%s%s\"", + sizeof(tmp_path), ret, + consumer->dst.session_root_path, + consumer->chunk_path, + consumer->subdir); + goto error; } pathname = lttng_strndup(tmp_path, sizeof(tmp_path)); if (!pathname) { @@ -75,6 +82,12 @@ static char *create_channel_path(struct consumer_output *consumer, if (ret < 0) { PERROR("snprintf kernel metadata path"); goto error; + } else if (ret >= sizeof(tmp_path)) { + ERR("Kernel channel path exceeds the maximal allowed length of of %zu bytes (%i bytes required) with path \"%s%s\"", + sizeof(tmp_path), ret, + consumer->dst.net.base_dir, + consumer->subdir); + goto error; } pathname = lttng_strndup(tmp_path, sizeof(tmp_path)); if (!pathname) { -- 2.34.1