Skip to content

Commit

Permalink
ignore number_entry_cd when recover
Browse files Browse the repository at this point in the history
  • Loading branch information
Coeur authored and nmoinvaz committed Nov 18, 2024
1 parent d7f5fdd commit 6d45beb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compat/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ unzFile unzOpen_MZ(void *stream) {
if (!handle)
return NULL;

mz_zip_set_recover(handle, 1);

err = mz_zip_open(handle, stream, MZ_OPEN_MODE_READ);
if (err != MZ_OK) {
mz_zip_delete(&handle);
Expand Down
3 changes: 2 additions & 1 deletion mz_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,8 @@ static int32_t mz_zip_read_cd(void *handle) {
if (err == MZ_OK)
err = mz_stream_read_uint16(zip->stream, &value16);
number_entry_cd = value16;
if (number_entry_cd != zip->number_entry)
/* When recover is enabled, we can ignore incorrect number of entries */
if (number_entry_cd != zip->number_entry && !zip->recover)
err = MZ_FORMAT_ERROR;
/* Size of the central directory */
if (err == MZ_OK)
Expand Down
Binary file not shown.

0 comments on commit 6d45beb

Please sign in to comment.