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