selmf / unarr

A decompression library for rar, tar, zip and 7z archives
GNU Lesser General Public License v3.0
73 stars 13 forks source link

more clear API documentation for ar_parse_entry failed situation ? #6

Open comicfans opened 5 years ago

comicfans commented 5 years ago

Hello, while fuzzing unarr I've found that if ar_parse_entry failed, archive entry_offset_next will never be increased , so that means it can not 'skip' the bad entry and continue to end, is this expected behavior ? maybe better to add description for this situation to header comment.

selmf commented 5 years ago

Yes, this is expected behaviour. In many cases when the entry header is corrupted, it no longer is possible to calculate the address of the next entry. We could try to locate the next entry by searching for its header signature (using memcmp, for example), but this isn't implemented yet and only works for non-solid compressions. In case of solid compressions, decompression of an entry depends on the decompression dictionary left by the previous entry, so if one entry is corrupt all entries after that can no longer be decompressed.