relayd: clean-up: strncpy uses the length of the source as length
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 14 Sep 2019 20:53:22 +0000 (16:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 19 Sep 2019 19:31:49 +0000 (15:31 -0400)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/cmd-2-4.c

index f420ad928ee0e4faf36c5c8f49f3df2bff734383..ac6e0425877970f3da91b05911fa8dc0c644609b 100644 (file)
@@ -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);
This page took 0.025784 seconds and 4 git commands to generate.