X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fcmd-2-2.c;h=4f34d8b66470ba90590e8f895f28e27f607bbc89;hp=47567b6203212a6b9ee5408e489d156436253ed1;hb=246777db6078ff9dd8046d5701fc12cb34547402;hpb=2855532e5118d79661ef728cdb59dbab7857be3e diff --git a/src/bin/lttng-relayd/cmd-2-2.c b/src/bin/lttng-relayd/cmd-2-2.c index 47567b620..4f34d8b66 100644 --- a/src/bin/lttng-relayd/cmd-2-2.c +++ b/src/bin/lttng-relayd/cmd-2-2.c @@ -19,12 +19,13 @@ #define _LGPL_SOURCE #include -#include #include #include #include +#include +#include #include "cmd-generic.h" #include "cmd-2-1.h" @@ -41,6 +42,7 @@ int cmd_recv_stream_2_2(struct relay_connection *conn, struct lttcomm_relayd_add_stream_2_2 stream_info; char *path_name = NULL; char *channel_name = NULL; + size_t len; ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info)); if (ret < 0) { @@ -48,17 +50,29 @@ int cmd_recv_stream_2_2(struct relay_connection *conn, goto error; } + len = lttng_strnlen(stream_info.pathname, sizeof(stream_info.pathname)); + /* Ensure that NULL-terminated and fits in local filename length. */ + if (len == sizeof(stream_info.pathname) || len >= LTTNG_NAME_MAX) { + ret = -ENAMETOOLONG; + ERR("Path name too long"); + goto error; + } path_name = create_output_path(stream_info.pathname); if (!path_name) { PERROR("Path name allocation"); ret = -ENOMEM; goto error; } - + len = lttng_strnlen(stream_info.channel_name, sizeof(stream_info.channel_name)); + if (len == sizeof(stream_info.channel_name) || len >= DEFAULT_STREAM_NAME_LEN) { + ret = -ENAMETOOLONG; + ERR("Channel name too long"); + goto error; + } channel_name = strdup(stream_info.channel_name); if (!channel_name) { ret = -errno; - PERROR("Path name allocation"); + PERROR("Channel name allocation"); goto error; }