Skip to content

Various robustness improvements#88

Merged
hniksic merged 12 commits intomasterfrom
hardening
Apr 30, 2026
Merged

Various robustness improvements#88
hniksic merged 12 commits intomasterfrom
hardening

Conversation

@hniksic
Copy link
Copy Markdown
Owner

@hniksic hniksic commented Apr 30, 2026

No description provided.

hniksic added 12 commits April 28, 2026 22:44
Aligns with other file-handle wrappers in win32.rs (ReadFileOverlapped,
WriteFileOverlapped, cancel_and_wait_io) and drops the Hungarian param
names.
When a redirection's File has a raw fd matching the target stream fd,
install_child_fd cleared CLOEXEC but then closed the fd via
prevent_dealloc, leaving the child without that standard stream after
exec.
Setting up stdin/stdout/stderr one at a time was buggy when a redirection
File's raw fd collided with another stream's target.  This caused several
issues:

* the fd got overwritten (or swapped) before the next stream was set up;
* an inherited standard stream at a low fd got closed when reused as a
  non-matching target;
* a shared Arc in Pipeline stderr_all/stdout_all leaked the source fd into
  non-last children.

This fixes the issues by resolving all three streams up front: any source fd
that another stream's dup2 would overwrite is pre-duped via F_DUPFD_CLOEXEC,
after which the streams are installed in fixed order.  Source fds at 3 or
above get CLOEXEC after dup2 so they close at exec, replacing the previous
count-based explicit close that missed shared-Arc cases.
@hniksic hniksic merged commit a8c12f5 into master Apr 30, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant