From: Jérémie Galarneau Date: Wed, 28 Feb 2018 21:32:26 +0000 (-0500) Subject: Fix: fail on truncation of kernel channel path X-Git-Tag: v2.11.0-rc1~304 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=dba13f1d5dffdd2ecaa14ba8ff88c27805153016;p=lttng-tools.git Fix: fail on truncation of kernel channel path Signed-off-by: Jérémie Galarneau --- 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) {