Fix: fail on truncation of kernel channel path
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 28 Feb 2018 21:32:26 +0000 (16:32 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 3 Apr 2018 16:12:29 +0000 (12:12 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/kernel-consumer.c

index 160c19f598329ec03c6d82023ad55f09bc38db03..74c4b302320de5b49926f1ff497c31b59f4fb9fa 100644 (file)
@@ -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) {
This page took 0.029683 seconds and 4 git commands to generate.