From: Jérémie Galarneau Date: Sat, 14 Sep 2019 20:53:22 +0000 (-0400) Subject: relayd: clean-up: strncpy uses the length of the source as length X-Git-Tag: v2.11.0-rc4~31 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=50b02b0ca4706b7a623a191360439b53ad69e010;p=lttng-tools.git relayd: clean-up: strncpy uses the length of the source as length strncpy is used with the source length of both session_name and hostname. This doesn't make sense at face value. However, this is not a "bug" as both src and dst are guaranteed to be the same length in all existing code paths. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/cmd-2-4.c b/src/bin/lttng-relayd/cmd-2-4.c index f420ad928..ac6e04258 100644 --- a/src/bin/lttng-relayd/cmd-2-4.c +++ b/src/bin/lttng-relayd/cmd-2-4.c @@ -53,8 +53,7 @@ int cmd_create_session_2_4(const struct lttng_buffer_view *payload, ERR("Session name too long"); goto error; } - strncpy(session_name, session_info.session_name, - sizeof(session_info.session_name)); + strncpy(session_name, session_info.session_name, LTTNG_PATH_MAX); len = lttng_strnlen(session_info.hostname, sizeof(session_info.hostname)); if (len == sizeof(session_info.hostname) || len >= LTTNG_HOST_NAME_MAX) { @@ -62,8 +61,7 @@ int cmd_create_session_2_4(const struct lttng_buffer_view *payload, ERR("Session name too long"); goto error; } - strncpy(hostname, session_info.hostname, - sizeof(session_info.hostname)); + strncpy(hostname, session_info.hostname, LTTNG_HOST_NAME_MAX); *live_timer = be32toh(session_info.live_timer); *snapshot = be32toh(session_info.snapshot);