Move buffer constant to #defines, cleanup. #543

This commit is contained in:
Nathan Moinvaziri 2020-12-23 11:50:24 -08:00
parent 4b2521978c
commit 161b266fb2

View File

@ -73,6 +73,7 @@
#define MZ_ZIP_SIZE_MAX_DATA_DESCRIPTOR (24)
#define MZ_ZIP_OFFSET_CRC_SIZES (14)
#define MZ_ZIP_UNCOMPR_SIZE64_CUSHION (2 * 1024 * 1024)
#ifndef MZ_ZIP_EOCD_MAX_BACK
#define MZ_ZIP_EOCD_MAX_BACK (1 << 20)
@ -553,14 +554,14 @@ static int32_t mz_zip_entry_needs_zip64(mz_zip_file *file_info, uint8_t local, u
uint8_t needs_zip64 = 0;
uint32_t max_uncompressed_size = UINT32_MAX;
/* At local header we might not know yet whether compressed_size will overflow unsigned
32-bit integer which might happen for high entropy data, so we add a 2MB buffer */
if (local)
max_uncompressed_size -= (2 * 1024 * 1024);
if (zip64 == NULL)
return MZ_PARAM_ERROR;
/* At local header we might not know yet whether compressed size will overflow unsigned
32-bit integer which might happen for high entropy data so we give it some cushion */
if (local)
max_uncompressed_size -= MZ_ZIP_UNCOMPR_SIZE64_CUSHION;
needs_zip64 = (file_info->uncompressed_size >= max_uncompressed_size) ||
(file_info->compressed_size >= UINT32_MAX) ||
(file_info->disk_offset >= UINT32_MAX);