From 23d9bbc3aa2009be74bb6bd773882f40a69e0083 Mon Sep 17 00:00:00 2001 From: minnnjuuu Date: Mon, 24 Aug 2026 20:42:47 +0900 Subject: [PATCH] Reject negative file descriptors in gzdopen() --- gzlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gzlib.c b/gzlib.c index 7a37a96cf0..78702174ca 100644 --- a/gzlib.c +++ b/gzlib.c @@ -299,7 +299,7 @@ gzFile ZEXPORT gzdopen(int fd, const char *mode) { char *path; /* identifier for error messages */ gzFile gz; - if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) + if (fd < 0 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) return NULL; #if !defined(NO_snprintf) && !defined(NO_vsnprintf) (void)snprintf(path, 7 + 3 * sizeof(int), "", fd);