Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
core: audit all uses of dup2() #256
Ensure every call to dup2() cannot result in a situation where the source and target FD are the same, and the source FD is later closed. Typical problem looks like:
if fd is coincidentally returned 0, then the target FD could be closed too, depending on state of file descriptor table at the time of call.
Fix might look something like:
In some cases, the source fd is not unmanaged, but belongs to e.g. a file() object. In that case, we must arrange for the target fd to exist even after the file object has closed.