Fix: fail on truncation of kernel channel path
[lttng-tools.git] / 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;
                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) {
                }
                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;
                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) {
                }
                pathname = lttng_strndup(tmp_path, sizeof(tmp_path));
                if (!pathname) {
This page took 0.023183 seconds and 4 git commands to generate.