Skip to content

Commit

Permalink
Revert "Remove noop __zipos_postdup" (#974)
Browse files Browse the repository at this point in the history
`close` does not modify the fd table, so `rc` can potentially have a
stale zipos object sitting on it. As such, we need `__zipos_postdup`
there.
  • Loading branch information
mrdomino authored Dec 1, 2023
1 parent 7845495 commit f0bfabb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libc/calls/fcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/runtime/zipos.internal.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/f.h"
#include "libc/sysv/errfuns.h"

Expand Down Expand Up @@ -125,6 +126,10 @@ int fcntl(int fd, int cmd, ...) {
END_CANCELATION_POINT;
} else {
rc = sys_fcntl(fd, cmd, arg, __sys_fcntl);
if (rc != -1 && (cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC) &&
__isfdkind(rc, kFdZip)) {
_weaken(__zipos_postdup)(fd, rc);
}
}
} else {
rc = sys_fcntl_nt(fd, cmd, arg);
Expand Down

0 comments on commit f0bfabb

Please sign in to comment.