madler / sunzip

Streaming unzip utility.
70 stars 29 forks source link

Fix validation errors on valid archives #9

Open Tulon opened 2 years ago

Tulon commented 2 years ago

I was getting the following error with one of my archives:

sunzip error: compressed data corrupted, check values mismatch in entry #3617 at offset 0x1119fc19 sunzip abort: zip file corrupted -- cannot continue

Unfortunately I can't share the archive itself, but I've found a problem in sunzip that causes this validation error.

The problem was the value of in->count being modified as a side effect of reading the data descriptor with get*() calls. Then, the GOOD() macro was comparing against that modified value, which was causing the validation error.

Such a situation may happen when the value of strm->avail_in after the inflateBack() call is smaller than the size of the data descriptor following the compressed data.