Commit 5c47755 for zlib
commit 5c47755331cb7354133b82f357ed767578c95649
Author: gaoshutao <1779227906@qq.com>
Date: Mon Aug 25 15:38:00 2025 +0800
Check for invalid NULL pointer inputs to zlib operations.
diff --git a/compress.c b/compress.c
index 0c80988..410d6e5 100644
--- a/compress.c
+++ b/compress.c
@@ -28,6 +28,10 @@ int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
const uInt max = (uInt)-1;
z_size_t left;
+ if ((sourceLen > 0 && source == NULL) ||
+ destLen == NULL || (*destLen > 0 && dest == NULL))
+ return Z_STREAM_ERROR;
+
left = *destLen;
*destLen = 0;
diff --git a/gzlib.c b/gzlib.c
index 65a0b49..934688c 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -93,7 +93,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
#endif
/* check input */
- if (path == NULL)
+ if (path == NULL || mode == NULL)
return NULL;
/* allocate gzFile structure to return */
diff --git a/uncompr.c b/uncompr.c
index 8f7438e..14ef96c 100644
--- a/uncompr.c
+++ b/uncompr.c
@@ -33,6 +33,10 @@ int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
const uInt max = (uInt)-1;
z_size_t len, left;
+ if (sourceLen == NULL || (*sourceLen > 0 && source == NULL) ||
+ destLen == NULL || (*destLen > 0 && dest == NULL))
+ return Z_STREAM_ERROR;
+
len = *sourceLen;
left = *destLen;
if (left == 0 && dest == Z_NULL)