Fix: possible null dereference
[lttng-tools.git] / src / bin / lttng-relayd / cmd-2-4.c
index ac6e0425877970f3da91b05911fa8dc0c644609b..02edb7713e54245b2c55beb6ec6ffb94ed4499e6 100644 (file)
@@ -1,20 +1,10 @@
 /*
- * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
- *                      David Goulet <dgoulet@efficios.com>
- *               2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * 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,8 +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, LTTNG_PATH_MAX);
+       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) {
This page took 0.023586 seconds and 4 git commands to generate.