Fix: liblttng-ctl: unreported truncations when copying strings
[lttng-tools.git] / src / lib / lttng-ctl / load.c
index e70a87d9228ae994a3da007b859a44ed11039be1..d55e3b0b4107b12c0cb5e84ef9e0e6aacb22354d 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';
        }
@@ -235,8 +240,12 @@ int lttng_load_session_attr_set_input_url(
        }
 
        /* Copy string plus the NULL terminated byte. */
-       lttng_ctl_copy_string(attr->input_url, uris[0].dst.path,
+       ret = lttng_strncpy(attr->input_url, uris[0].dst.path,
                        sizeof(attr->input_url));
+       if (ret) {
+               ret = -LTTNG_ERR_INVALID;
+               goto error;
+       }
 
 end:
 error:
This page took 0.02416 seconds and 4 git commands to generate.