Commit 2ec717a for zlib
commit 2ec717a141cbf9091e1d914c15e30278efed5127
Author: ronald.eytchison@trailofbits.com <ronald.eytchison@trailofbits.com>
Date: Fri Jun 5 19:10:15 2026 +0000
Fix gzdopen close-on-exec to use the correct flag.
Reported by Trail of Bits (TOB-ZLIB-008).
diff --git a/gzlib.c b/gzlib.c
index 8204149..a7aec74 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -256,9 +256,9 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
if (oflag & O_NONBLOCK)
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
#endif
-#ifdef O_CLOEXEC
+#if defined(O_CLOEXEC) && defined(FD_CLOEXEC)
if (oflag & O_CLOEXEC)
- fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_CLOEXEC);
+ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
#endif
state->fd = fd;
}