sessiond: fix: strncpy called with source length
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 15 Sep 2019 18:27:40 +0000 (14:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 15 Sep 2019 18:27:40 +0000 (14:27 -0400)
strncpy is called with the source's length in two cases in the
session save code. Use the destination and remaining destination
length as intended by the API.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/save.c

index 00cdd9364d5f4ff6c7b438debfb66972b9084e4b..3c4c3b2bce527045f7c1c9d3c09f00773fd68a07 100644 (file)
@@ -2285,7 +2285,7 @@ int save_session(struct ltt_session *session,
        struct lttng_save_session_attr *attr, lttng_sock_cred *creds)
 {
        int ret, fd = -1;
-       char config_file_path[PATH_MAX];
+       char config_file_path[LTTNG_PATH_MAX];
        size_t len;
        struct config_writer *writer = NULL;
        size_t session_name_len;
@@ -2313,7 +2313,7 @@ int save_session(struct ltt_session *session,
                        ret = LTTNG_ERR_SET_URL;
                        goto end;
                }
-               strncpy(config_file_path, provided_path, len);
+               strncpy(config_file_path, provided_path, sizeof(config_file_path));
        } else {
                ssize_t ret_len;
                char *home_dir = utils_get_user_home_dir(
@@ -2357,7 +2357,7 @@ int save_session(struct ltt_session *session,
         * was done just above.
         */
        config_file_path[len++] = '/';
-       strncpy(config_file_path + len, session->name, session_name_len);
+       strncpy(config_file_path + len, session->name, sizeof(config_file_path) - len);
        len += session_name_len;
        strcpy(config_file_path + len, DEFAULT_SESSION_CONFIG_FILE_EXTENSION);
        len += sizeof(DEFAULT_SESSION_CONFIG_FILE_EXTENSION);
This page took 0.029588 seconds and 5 git commands to generate.