diff options
| author | Mark Adler <git@madler.net> | 2025-12-21 18:17:56 -0800 |
|---|---|---|
| committer | Mark Adler <git@madler.net> | 2026-01-05 15:03:04 -0600 |
| commit | ba829a458576d1ff0f26fc7230c6de816d1f6a77 (patch) | |
| tree | b955e6951991dbb4aed9c556a6f2b28645ca95fb /crc32.c | |
| parent | 570720b0c24f9686c33f35a1b3165c1f568b96be (diff) | |
| download | zlib-ba829a458576d1ff0f26fc7230c6de816d1f6a77.tar.gz zlib-ba829a458576d1ff0f26fc7230c6de816d1f6a77.tar.bz2 zlib-ba829a458576d1ff0f26fc7230c6de816d1f6a77.zip | |
Check for negative lengths in crc32_combine functions.
Though zlib.h says that len2 must be non-negative, this avoids the
possibility of an accidental infinite loop.
Diffstat (limited to 'crc32.c')
| -rw-r--r-- | crc32.c | 4 |
1 files changed, 4 insertions, 0 deletions
| @@ -1019,6 +1019,8 @@ unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, | |||
| 1019 | 1019 | ||
| 1020 | /* ========================================================================= */ | 1020 | /* ========================================================================= */ |
| 1021 | uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { | 1021 | uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { |
| 1022 | if (len2 < 0) | ||
| 1023 | return 0; | ||
| 1022 | #ifdef DYNAMIC_CRC_TABLE | 1024 | #ifdef DYNAMIC_CRC_TABLE |
| 1023 | once(&made, make_crc_table); | 1025 | once(&made, make_crc_table); |
| 1024 | #endif /* DYNAMIC_CRC_TABLE */ | 1026 | #endif /* DYNAMIC_CRC_TABLE */ |
| @@ -1032,6 +1034,8 @@ uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { | |||
| 1032 | 1034 | ||
| 1033 | /* ========================================================================= */ | 1035 | /* ========================================================================= */ |
| 1034 | uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { | 1036 | uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { |
| 1037 | if (len2 < 0) | ||
| 1038 | return 0; | ||
| 1035 | #ifdef DYNAMIC_CRC_TABLE | 1039 | #ifdef DYNAMIC_CRC_TABLE |
| 1036 | once(&made, make_crc_table); | 1040 | once(&made, make_crc_table); |
| 1037 | #endif /* DYNAMIC_CRC_TABLE */ | 1041 | #endif /* DYNAMIC_CRC_TABLE */ |
