Only check RAR5 signature elsewhere on executables #170
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously the
RAR5
signature was checked in all the available "header" bytes.This is prone to issues for example if a TAR contains some
RAR5
files giving false detections and incomplete or failed extractions.To fix this I'm just adding an executable signature check (
MZ
) before using all length orRAR5MaximumSFXHeader
to check for theRAR5
signature.I'm attaching some example files:
rar-v4.tar
: contains a RAR4 file. Is detected as TAR and extracts the bare .rar file.rar-v5.tar
: contains a RAR5 file. Is detected as RAR5 and extracts the contents of the RAR inside the TAR.parted-rar-v5.tar
: contains a three parts RAR5 volume. Is detected asRAR5
and fails as tries to extract the first part found.Did not tried but I'm assuming if the TAR file contains more files a part from the
RAR5
, and this one is detected, the other files will be dismissed.Examples.zip