Fixed zip64 not being written if no values used where it should be.

Fixed wrong compressed size for lzma.
This commit is contained in:
Nathan Moinvaziri 2017-10-05 08:26:59 -07:00
parent 524286d116
commit c48c15314e
2 changed files with 6 additions and 9 deletions

View File

@ -92,6 +92,8 @@ int32_t mz_stream_lzma_open(void *stream, const char *path, int mode)
mz_stream_write_uint8(lzma->stream.base, LZMA_VERSION_MINOR);
mz_stream_write_uint16(lzma->stream.base, size);
lzma->total_out += 4;
lzma->error = lzma_alone_encoder(&lzma->lstream, &opt_lzma);
}

View File

@ -451,8 +451,6 @@ extern int ZEXPORT mz_zip_entry_open(void *handle, const mz_zip_file *file_info,
if (zip->pos_local_header >= UINT32_MAX)
zip->file_info.zip64 = 1;
zip->number_disk = zip->number_disk;
// Write the local header
if (err == MZ_OK)
err = mz_stream_write_uint32(zip->stream, (uint32_t)LOCALHEADERMAGIC);
@ -727,18 +725,15 @@ extern int ZEXPORT mz_zip_entry_close_raw(void *handle, uint64_t uncompressed_si
if (zip->file_info.zip64)
{
version_needed = 45;
extrafield_zip64_size += 4;
if (uncompressed_size >= UINT32_MAX)
extrafield_zip64_size += 8;
if (compressed_size >= UINT32_MAX)
extrafield_zip64_size += 8;
if (zip->pos_local_header >= UINT32_MAX)
extrafield_zip64_size += 8;
if (extrafield_zip64_size > 0)
{
extrafield_zip64_size += 4;
extrafield_size += extrafield_zip64_size;
}
}
#ifdef HAVE_AES
if ((zip->file_info.flag & 1) && (zip->crypt_info.aes))
{
@ -789,7 +784,7 @@ extern int ZEXPORT mz_zip_entry_close_raw(void *handle, uint64_t uncompressed_si
mz_stream_write(zip->cd_stream, zip->file_info.extrafield_global, zip->file_info.extrafield_global_size);
// Add ZIP64 extra info header to central directory
if ((zip->file_info.zip64) && (extrafield_zip64_size > 0))
if (zip->file_info.zip64)
{
mz_stream_write_uint16(zip->cd_stream, 0x0001);
mz_stream_write_uint16(zip->cd_stream, extrafield_zip64_size);