Fix: illegal memory access in write_pidfile
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 433b15b76c7f30de89c66506df829842a238b6d4..92899873baebd743c5de265f795b41ae00f22498 100644 (file)
@@ -5348,7 +5348,10 @@ static int write_pidfile(void)
        assert(rundir);
 
        if (opt_pidfile) {
-               strncpy(pidfile_path, opt_pidfile, sizeof(pidfile_path));
+               if (lttng_strncpy(pidfile_path, opt_pidfile, sizeof(pidfile_path))) {
+                       ret = -1;
+                       goto error;
+               }
        } else {
                /* Build pidfile path from rundir and opt_pidfile. */
                ret = snprintf(pidfile_path, sizeof(pidfile_path), "%s/"
@@ -6100,11 +6103,12 @@ exit_health_sessiond_cleanup:
 exit_create_run_as_worker_cleanup:
 
 exit_options:
+       /* Ensure all prior call_rcu are done. */
+       rcu_barrier();
+
        sessiond_cleanup_options();
 
 exit_set_signal_handler:
-       /* Ensure all prior call_rcu are done. */
-       rcu_barrier();
 
        if (!retval) {
                exit(EXIT_SUCCESS);
This page took 0.023822 seconds and 4 git commands to generate.