@@ -58,6 +58,10 @@ int fr_exec_value_box_list_to_argv(TALLOC_CTX *ctx, char ***argv_p, fr_value_box
5858 */
5959 first = fr_value_box_list_head (in );
6060 if (first -> type == FR_TYPE_GROUP ) first = fr_value_box_list_head (& first -> vb_group );
61+ if (!first ) {
62+ fr_strerror_const ("No program to run" );
63+ return -1 ;
64+ }
6165 if (first -> tainted ) {
6266 fr_strerror_printf ("Program to run comes from tainted source - %pV" , first );
6367 return -1 ;
@@ -419,7 +423,7 @@ char **exec_build_env(char **env_in, bool env_inherit)
419423 /*
420424 * No room to copy anything after the environment variables.
421425 */
422- if (((num_environ + 1 ) = = NUM_ELEMENTS (env_exec_arr ))) {
426+ if (((num_environ + 1 ) > = NUM_ELEMENTS (env_exec_arr ))) {
423427 return environ ;
424428 }
425429
@@ -540,7 +544,10 @@ int fr_exec_fork_wait(pid_t *pid_p,
540544 error1 :
541545 return -1 ;
542546 }
543- if (fr_nonblock (stdin_pipe [1 ]) < 0 ) fr_strerror_const ("Error setting stdin to nonblock" );
547+ if (fr_nonblock (stdin_pipe [1 ]) < 0 ) {
548+ fr_strerror_const ("Error setting stdin to nonblock" );
549+ goto error2 ;
550+ }
544551 }
545552
546553 if (stdout_fd ) {
@@ -552,7 +559,10 @@ int fr_exec_fork_wait(pid_t *pid_p,
552559 close (stdin_pipe [1 ]);
553560 goto error1 ;
554561 }
555- if (fr_nonblock (stdout_pipe [0 ]) < 0 ) fr_strerror_const ("Error setting stdout to nonblock" );
562+ if (fr_nonblock (stdout_pipe [0 ]) < 0 ) {
563+ fr_strerror_const ("Error setting stdout to nonblock" );
564+ goto error3 ;
565+ }
556566 }
557567
558568 if (stderr_fd ) {
@@ -564,7 +574,12 @@ int fr_exec_fork_wait(pid_t *pid_p,
564574 close (stdout_pipe [1 ]);
565575 goto error2 ;
566576 }
567- if (fr_nonblock (stderr_pipe [0 ]) < 0 ) fr_strerror_const ("Error setting stderr to nonblock" );
577+ if (fr_nonblock (stderr_pipe [0 ]) < 0 ) {
578+ fr_strerror_const ("Error setting stderr to nonblock" );
579+ close (stderr_pipe [0 ]);
580+ close (stderr_pipe [1 ]);
581+ goto error3 ;
582+ }
568583 }
569584
570585 env = exec_build_env (env_in , env_inherit );
0 commit comments