]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Always initialise the output PID even on error
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 14 Nov 2022 16:57:57 +0000 (10:57 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 14 Nov 2022 16:58:11 +0000 (10:58 -0600)
src/lib/server/exec.c

index 3f6397a32e06b2658a08abdd15460bdd16c4e3ae..6f82eb9c9daa662fdfe32cc274bc692c14e74314 100644 (file)
@@ -418,10 +418,10 @@ int fr_exec_fork_nowait(request_t *request, fr_value_box_list_t *args,
 
 /** Execute a program assuming that the caller waits for it to finish.
  *
- *  The caller takes responsibility for calling waitpid() on the returned PID.
+ * The caller takes responsibility for calling waitpid() on the returned PID.
  *
- *  The caller takes responsibility for reading from the returned FD,
- *  and closing it.
+ * The caller takes responsibility for reading from the returned FD,
+ * and closing it.
  *
  * @param[out] pid_p           The PID of the child
  * @param[out] stdin_fd                The stdin FD of the child.
@@ -547,6 +547,7 @@ int fr_exec_fork_wait(pid_t *pid_p, int *stdin_fd, int *stdout_fd, int *stderr_f
                close(stdout_pipe[1]);
                close(stderr_pipe[0]);
                close(stderr_pipe[1]);
+               *pid_p = -1;    /* Ensure the PID is set even if the caller didn't check the return code */
                talloc_free(argv);
                return -1;
        }