Fix: illegal memory access in relayd_create_session_2_4
[lttng-tools.git] / src / common / relayd / relayd.c
index 3de19c28064d352ef9e1d507f14bac3cd318a823..8f4f07a2088f75fbe0774bb240eb1d887806d958 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #define _GNU_SOURCE
+#define _LGPL_SOURCE
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -25,6 +26,7 @@
 
 #include <common/common.h>
 #include <common/defaults.h>
+#include <common/compat/endian.h>
 #include <common/sessiond-comm/relayd.h>
 #include <common/index/ctf-index.h>
 
@@ -128,8 +130,15 @@ static int relayd_create_session_2_4(struct lttcomm_relayd_sock *rsock,
        int ret;
        struct lttcomm_relayd_create_session_2_4 msg;
 
-       strncpy(msg.session_name, session_name, sizeof(msg.session_name));
-       strncpy(msg.hostname, hostname, sizeof(msg.hostname));
+       if (lttng_strncpy(msg.session_name, session_name,
+                       sizeof(msg.session_name))) {
+               ret = -1;
+               goto error;
+       }
+       if (lttng_strncpy(msg.hostname, hostname, sizeof(msg.hostname))) {
+               ret = -1;
+               goto error;
+       }
        msg.live_timer = htobe32(session_live_timer);
        msg.snapshot = htobe32(snapshot);
 
This page took 0.024209 seconds and 4 git commands to generate.