X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Frotate.c;h=17964fb1070784b9b65badf61eca9a94da9e819c;hb=d37406195ec30adfb1bd903e3ee8dfdda79700ef;hp=bc3a63cc8aa67d8a0bd089e32b56677d0795039f;hpb=7370c9557408fc19f87958c204a51b6342f24208;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/rotate.c b/src/lib/lttng-ctl/rotate.c index bc3a63cc8..17964fb10 100644 --- a/src/lib/lttng-ctl/rotate.c +++ b/src/lib/lttng-ctl/rotate.c @@ -1,18 +1,8 @@ /* - * Copyright (C) 2017 - Julien Desfossez + * Copyright (C) 2017 Julien Desfossez * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License, version 2.1 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: LGPL-2.1-only * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #define _LGPL_SOURCE @@ -179,7 +169,7 @@ void lttng_rotation_handle_destroy( if (!rotation_handle) { return; } - lttng_trace_archive_location_destroy(rotation_handle->archive_location); + lttng_trace_archive_location_put(rotation_handle->archive_location); free(rotation_handle); } @@ -229,8 +219,11 @@ int lttng_rotate_session(const char *session_name, memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTNG_ROTATE_SESSION; - lttng_ctl_copy_string(lsm.session.name, session_name, - sizeof(lsm.session.name)); + + ret = lttng_strncpy(lsm.session.name, session_name, + sizeof(lsm.session.name)); + /* Source length already validated. */ + assert(ret == 0); ret = lttng_ctl_ask_sessiond(&lsm, (void **) &rotate_return); if (ret <= 0) { @@ -292,8 +285,10 @@ enum lttng_rotation_status lttng_rotation_update_schedule( memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTNG_ROTATION_SET_SCHEDULE; - lttng_ctl_copy_string(lsm.session.name, session_name, + ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name)); + /* Source length already validated. */ + assert(ret == 0); lsm.u.rotation_set_schedule.type = (uint32_t) schedule->type; switch (schedule->type) { @@ -372,14 +367,23 @@ int get_schedules(const char *session_name, { int ret; struct lttcomm_session_msg lsm; - struct lttng_session_list_schedules_return *schedules_comm; + struct lttng_session_list_schedules_return *schedules_comm = NULL; struct lttng_rotation_schedules *schedules = NULL; struct lttng_rotation_schedule *periodic = NULL, *size = NULL; + if (!session_name) { + ret = -LTTNG_ERR_INVALID; + goto end; + } + memset(&lsm, 0, sizeof(lsm)); lsm.cmd_type = LTTNG_SESSION_LIST_ROTATION_SCHEDULES; - lttng_ctl_copy_string(lsm.session.name, session_name, + ret = lttng_strncpy(lsm.session.name, session_name, sizeof(lsm.session.name)); + if (ret) { + ret = -LTTNG_ERR_INVALID; + goto end; + } ret = lttng_ctl_ask_sessiond(&lsm, (void **) &schedules_comm); if (ret < 0) {