mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-07 03:23:18 +01:00
gspawn: Error out early if a target FD is invalid
Rather than passing it to `dup2()`, which scan-build thinks could cause problems (I would have thought `dup2()` would just return `EBADF`, but perhaps some implementations are buggy?). Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
@@ -923,7 +923,8 @@ do_exec (gint child_err_report_fd,
|
||||
child_err_report_fd = new_child_err_report_fd;
|
||||
}
|
||||
|
||||
if (safe_dup2 (source_fds[i], target_fds[i]) < 0)
|
||||
if (target_fds[i] < 0 ||
|
||||
safe_dup2 (source_fds[i], target_fds[i]) < 0)
|
||||
write_err_and_exit (child_err_report_fd, CHILD_DUPFD_FAILED);
|
||||
|
||||
g_clear_fd (&source_fds[i], NULL);
|
||||
|
||||
Reference in New Issue
Block a user