onekey-sec / unblob

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

Fix `is_valid_gzip` on empty file #793

Closed e3krisztian closed 7 months ago

e3krisztian commented 7 months ago

787 was fixing the issue #786 not just at the location of the problem, but this reached the File class as well, modifying it to raise an unblob specific error, effectively aborting processing in a "well known manner".

I think this was wrong, and File worked as expected and was a rather generic class, and should remain so. The fix also had changes in gzip and 7z handlers, ignoring empty files from the collected files, but that change was neither supported by tests nor explained - I think that was a redundant fix for the problem.

The root of the issue is not in the File class, but rather that the raised ValueError is not handled by the handler.

This MR reverts some changes and fixes only the failing function, covered with a test.