diff options
| author | gaoshutao <1779227906@qq.com> | 2025-08-25 15:38:00 +0800 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2026-02-11 11:51:20 -0800 |
| commit | 5c47755331cb7354133b82f357ed767578c95649 (patch) | |
| tree | c180103b055fd1feb3e9904e61a070c3ffd8f83e | |
| parent | d37e27eef65c6249631e8757601c43e813ded155 (diff) | |
| download | zlib-5c47755331cb7354133b82f357ed767578c95649.tar.gz zlib-5c47755331cb7354133b82f357ed767578c95649.tar.bz2 zlib-5c47755331cb7354133b82f357ed767578c95649.zip | |
Check for invalid NULL pointer inputs to zlib operations.
| -rw-r--r-- | compress.c | 4 | ||||
| -rw-r--r-- | gzlib.c | 2 | ||||
| -rw-r--r-- | uncompr.c | 4 |
3 files changed, 9 insertions, 1 deletions
| @@ -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 | ||
| @@ -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 */ |
| @@ -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) |
