X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fcmd-2-4.c;h=02edb7713e54245b2c55beb6ec6ffb94ed4499e6;hp=aeb760a043f773a86ef9d417f31fe36f16854fda;hb=640b9481e1805d314256361ed49d55dcc35d6172;hpb=5312a3edd938117cb5670de711f237e7b6f2e68c diff --git a/src/bin/lttng-relayd/cmd-2-4.c b/src/bin/lttng-relayd/cmd-2-4.c index aeb760a04..02edb7713 100644 --- a/src/bin/lttng-relayd/cmd-2-4.c +++ b/src/bin/lttng-relayd/cmd-2-4.c @@ -1,20 +1,10 @@ /* - * Copyright (C) 2013 - Julien Desfossez - * David Goulet - * 2015 - Mathieu Desnoyers + * Copyright (C) 2013 Julien Desfossez + * Copyright (C) 2013 David Goulet + * Copyright (C) 2015 Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program 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 General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -52,9 +42,12 @@ int cmd_create_session_2_4(const struct lttng_buffer_view *payload, ret = -ENAMETOOLONG; ERR("Session name too long"); goto error; + } else if (len == 0) { + ret = -EINVAL; + ERR("Session name can't be of length 0"); + goto error; } - strncpy(session_name, session_info.session_name, - sizeof(session_info.session_name)); + strncpy(session_name, session_info.session_name, LTTNG_NAME_MAX); len = lttng_strnlen(session_info.hostname, sizeof(session_info.hostname)); if (len == sizeof(session_info.hostname) || len >= LTTNG_HOST_NAME_MAX) { @@ -62,8 +55,8 @@ 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);