aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgaoshutao <1779227906@qq.com>2025-08-25 15:38:00 +0800
committerMark Adler <git@madler.net>2026-02-11 11:51:20 -0800
commit5c47755331cb7354133b82f357ed767578c95649 (patch)
treec180103b055fd1feb3e9904e61a070c3ffd8f83e
parentd37e27eef65c6249631e8757601c43e813ded155 (diff)
downloadzlib-5c47755331cb7354133b82f357ed767578c95649.tar.gz
zlib-5c47755331cb7354133b82f357ed767578c95649.tar.bz2
zlib-5c47755331cb7354133b82f357ed767578c95649.zip
Check for invalid NULL pointer inputs to zlib operations.
-rw-r--r--compress.c4
-rw-r--r--gzlib.c2
-rw-r--r--uncompr.c4
3 files changed, 9 insertions, 1 deletions
diff --git a/compress.c b/compress.c
index 0c809880..410d6e50 100644
--- a/compress.c
+++ b/compress.c
@@ -28,6 +28,10 @@ int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
28 const uInt max = (uInt)-1; 28 const uInt max = (uInt)-1;
29 z_size_t left; 29 z_size_t left;
30 30
31 if ((sourceLen > 0 && source == NULL) ||
32 destLen == NULL || (*destLen > 0 && dest == NULL))
33 return Z_STREAM_ERROR;
34
31 left = *destLen; 35 left = *destLen;
32 *destLen = 0; 36 *destLen = 0;
33 37
diff --git a/gzlib.c b/gzlib.c
index 65a0b497..934688c5 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -93,7 +93,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
93#endif 93#endif
94 94
95 /* check input */ 95 /* check input */
96 if (path == NULL) 96 if (path == NULL || mode == NULL)
97 return NULL; 97 return NULL;
98 98
99 /* allocate gzFile structure to return */ 99 /* allocate gzFile structure to return */
diff --git a/uncompr.c b/uncompr.c
index 8f7438ee..14ef96ce 100644
--- a/uncompr.c
+++ b/uncompr.c
@@ -33,6 +33,10 @@ int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
33 const uInt max = (uInt)-1; 33 const uInt max = (uInt)-1;
34 z_size_t len, left; 34 z_size_t len, left;
35 35
36 if (sourceLen == NULL || (*sourceLen > 0 && source == NULL) ||
37 destLen == NULL || (*destLen > 0 && dest == NULL))
38 return Z_STREAM_ERROR;
39
36 len = *sourceLen; 40 len = *sourceLen;
37 left = *destLen; 41 left = *destLen;
38 if (left == 0 && dest == Z_NULL) 42 if (left == 0 && dest == Z_NULL)