Skip to content

Commit 09169eb

Browse files
committed
Use cleanup_fd to close intermediate pid sockets
This closes the fd and sets the variable to -1 as a single operation, which is easier to reason about because it does not leave any variables containing dangling references to invalid fds. Signed-off-by: Simon McVittie <[email protected]>
1 parent 3f0847d commit 09169eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bubblewrap.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,7 @@ main (int argc,
31483148
if (intermediate_pids_sockets[PIPE_READ_END] != -1)
31493149
{
31503150
pid = read_pid_from_socket (intermediate_pids_sockets[PIPE_READ_END]);
3151-
close (intermediate_pids_sockets[PIPE_READ_END]);
3151+
cleanup_fdp (&intermediate_pids_sockets[PIPE_READ_END]);
31523152
}
31533153

31543154
/* Discover namespace ids before we drop privileges */
@@ -3234,7 +3234,7 @@ main (int argc,
32343234

32353235
/* We're back, either in a child or grandchild, so message the actual pid to the monitor */
32363236
send_pid_on_socket (intermediate_pids_sockets[PIPE_WRITE_END]);
3237-
close (intermediate_pids_sockets[PIPE_WRITE_END]);
3237+
cleanup_fdp (&intermediate_pids_sockets[PIPE_WRITE_END]);
32383238
}
32393239

32403240
/* Child, in sandbox, privileged in the parent or in the user namespace (if --unshare-user).

0 commit comments

Comments
 (0)