From 61ba6b6dc790245afa7fbec89a9811f6c7603b00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 5 Mar 2018 11:09:42 -0500 Subject: [PATCH] Clean-up: use LTTNG_PATH_MAX rather than PATH_MAX 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/consumer.c | 2 +- src/bin/lttng-sessiond/consumer.h | 6 +++--- src/bin/lttng-sessiond/ust-app.c | 8 ++++---- src/bin/lttng-sessiond/ust-consumer.c | 11 +++++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 6351ebe32..5f551e31d 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -561,7 +561,7 @@ struct consumer_output *consumer_copy_output(struct consumer_output *obj) } output->enabled = obj->enabled; output->net_seq_index = obj->net_seq_index; - memcpy(output->subdir, obj->subdir, PATH_MAX); + memcpy(output->subdir, obj->subdir, sizeof(output->subdir)); output->snapshot = obj->snapshot; output->relay_major_version = obj->relay_major_version; output->relay_minor_version = obj->relay_minor_version; diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index ddc94d714..24c7a273c 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -169,7 +169,7 @@ struct consumer_output { * Subdirectory path name used for both local and network * consumer (/kernel or /ust). */ - char subdir[PATH_MAX]; + char subdir[LTTNG_PATH_MAX]; /* * Hashtable of consumer_socket index by the file descriptor value. For @@ -182,7 +182,7 @@ struct consumer_output { unsigned int snapshot:1; union { - char session_root_path[PATH_MAX]; + char session_root_path[LTTNG_PATH_MAX]; struct consumer_net net; } dst; @@ -190,7 +190,7 @@ struct consumer_output { * Sub-directory below the session_root_path where the next chunk of * trace will be stored (\0 before the first session rotation). */ - char chunk_path[PATH_MAX]; + char chunk_path[LTTNG_PATH_MAX]; }; struct consumer_socket *consumer_find_socket(int key, diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 9112cd14e..0db0eb173 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -4420,18 +4420,18 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) usess->consumer->dst.session_root_path[0] != '\0') { char *tmp_path; - tmp_path = zmalloc(PATH_MAX * sizeof(char)); + tmp_path = zmalloc(LTTNG_PATH_MAX); if (!tmp_path) { ERR("Alloc tmp_path"); goto error_unlock; } - ret = snprintf(tmp_path, PATH_MAX, "%s%s%s", + ret = snprintf(tmp_path, LTTNG_PATH_MAX, "%s%s%s", usess->consumer->dst.session_root_path, usess->consumer->chunk_path, usess->consumer->subdir); - if (ret >= PATH_MAX) { + if (ret >= LTTNG_PATH_MAX) { ERR("Local destination path exceeds the maximal allowed length of %i bytes (needs %i bytes) with path = \"%s%s%s\"", - PATH_MAX, ret, + LTTNG_PATH_MAX, ret, usess->consumer->dst.session_root_path, usess->consumer->chunk_path, usess->consumer->subdir); diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index eac995657..d8d6c329f 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -53,8 +53,11 @@ static char *setup_trace_path(struct consumer_output *consumer, health_code_update(); - /* Allocate our self the string to make sure we never exceed PATH_MAX. */ - pathname = zmalloc(PATH_MAX); + /* + * Allocate the string ourself to make sure we never exceed + * LTTNG_PATH_MAX. + */ + pathname = zmalloc(LTTNG_PATH_MAX); if (!pathname) { goto error; } @@ -62,7 +65,7 @@ static char *setup_trace_path(struct consumer_output *consumer, /* Get correct path name destination */ if (consumer->type == CONSUMER_DST_LOCAL) { /* Set application path to the destination path */ - ret = snprintf(pathname, PATH_MAX, "%s%s%s%s", + ret = snprintf(pathname, LTTNG_PATH_MAX, "%s%s%s%s", consumer->dst.session_root_path, consumer->chunk_path, consumer->subdir, ua_sess->path); @@ -81,7 +84,7 @@ static char *setup_trace_path(struct consumer_output *consumer, } } } else { - ret = snprintf(pathname, PATH_MAX, "%s%s%s%s", + ret = snprintf(pathname, LTTNG_PATH_MAX, "%s%s%s%s", consumer->dst.net.base_dir, consumer->chunk_path, consumer->subdir, -- 2.34.1