X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fcmd-2-1.c;h=5e2ed35ebe3e1ce6a30435a5f41f823026deb271;hp=080dc173fc8361b117b4d335c3c2895bd075342f;hb=d7b377ed1acd4043bde353d99122e0e56fa4e975;hpb=246777db6078ff9dd8046d5701fc12cb34547402 diff --git a/src/bin/lttng-relayd/cmd-2-1.c b/src/bin/lttng-relayd/cmd-2-1.c index 080dc173f..5e2ed35eb 100644 --- a/src/bin/lttng-relayd/cmd-2-1.c +++ b/src/bin/lttng-relayd/cmd-2-1.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 @@ -25,14 +15,13 @@ #include #include -#include "cmd-generic.h" #include "cmd-2-1.h" #include "utils.h" /* * cmd_recv_stream_2_1 allocates path_name and channel_name. */ -int cmd_recv_stream_2_1(struct relay_connection *conn, +int cmd_recv_stream_2_1(const struct lttng_buffer_view *payload, char **ret_path_name, char **ret_channel_name) { int ret; @@ -41,11 +30,13 @@ int cmd_recv_stream_2_1(struct relay_connection *conn, char *channel_name = NULL; size_t len; - ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info)); - if (ret < 0) { - ERR("Unable to recv stream version 2.1"); + if (payload->size < sizeof(stream_info)) { + ERR("Unexpected payload size in \"cmd_recv_stream_2_1\": expected >= %zu bytes, got %zu bytes", + sizeof(stream_info), payload->size); + ret = -1; goto error; } + memcpy(&stream_info, payload->data, sizeof(stream_info)); len = lttng_strnlen(stream_info.pathname, sizeof(stream_info.pathname)); /* Ensure that NULL-terminated and fits in local filename length. */ @@ -54,7 +45,7 @@ int cmd_recv_stream_2_1(struct relay_connection *conn, ERR("Path name too long"); goto error; } - path_name = create_output_path(stream_info.pathname); + path_name = strdup(stream_info.pathname); if (!path_name) { PERROR("Path name allocation"); ret = -ENOMEM;