Replace strncpy by lttng_strncpy in lttngctl session configuration API
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 4 Jun 2018 15:27:37 +0000 (11:27 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 4 Jun 2018 16:00:13 +0000 (12:00 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/lib/lttng-ctl/load.c
src/lib/lttng-ctl/save.c

index e70a87d9228ae994a3da007b859a44ed11039be1..0f9ccfa0e86143800a7be426f0574df1d6ba8274 100644 (file)
@@ -195,7 +195,12 @@ int lttng_load_session_attr_set_session_name(
                        goto error;
                }
 
-               strncpy(attr->session_name, session_name, len);
+               ret = lttng_strncpy(attr->session_name, session_name,
+                               sizeof(attr->session_name));
+               if (ret) {
+                       ret = -LTTNG_ERR_INVALID;
+                       goto error;
+               }
        } else {
                attr->session_name[0] = '\0';
        }
index 555006d0aff1350938c450aea93f481583a6b018..8302226644f89f708394e78f6a51ddf2eba061c2 100644 (file)
@@ -99,7 +99,12 @@ int lttng_save_session_attr_set_session_name(
                        goto error;
                }
 
-               strncpy(attr->session_name, session_name, len);
+               ret = lttng_strncpy(attr->session_name, session_name,
+                               sizeof(attr->session_name));
+               if (ret) {
+                       ret = -LTTNG_ERR_INVALID;
+                       goto error;
+               }
        } else {
                attr->session_name[0] = '\0';
        }
This page took 0.028927 seconds and 4 git commands to generate.