onekey-sec / unblob

Extract files from any kind of container formats
https://unblob.org
Other
2.11k stars 80 forks source link

fix(gzip): empty files are invalid and should not be parsed #787

Closed AndrewFasano closed 4 months ago

AndrewFasano commented 4 months ago

Passing an empty file into File.from_path leads to an error that an empty file cannot be mmaped.

This could also be implemented in the from_path method, but I thought the is_valid method made since because an empty file isn't a valid gzip.

Fixes #786

qkaiser commented 4 months ago

Thanks @AndrewFasano ! I took the liberty to work on your branch to also cover the sevenzip multi-volume handler and add some checks in the File class + testing.

This is something that came up when I worked on fuzzing (see https://github.com/onekey-sec/unblob/blob/main/fuzzing/search_chunks_fuzzer.py#L50) but I left it on the side.

Will request a review from the team.