Fix condition in rar v3 code#894
Merged
adamhathcock merged 4 commits intoadamhathcock:masterfrom Feb 11, 2025
Merged
Conversation
adamhathcock
approved these changes
Feb 11, 2025
Owner
adamhathcock
left a comment
There was a problem hiding this comment.
Seems valid to me, not sure what to do to ensure this doesn't happen again. Tests or comments?
Contributor
Author
|
A test would be great but I don't know how to generate an archive that would exhibit this problem, I only used the archive provided in #890 to test this. I can add a comment to |
Owner
|
I'm imagining it has the same issue but I'm not an expert with it |
Owner
|
either this PR (or possible the OpenRead) PR has seemingly broke a disposing test on the reader? |
Contributor
Author
|
welp, it looks like applying this same diff on the rar5 code breaks it... not very reassuring. |
... yeah... apparently the thing that fixes rar3 code breaks rar5 code
adamhathcock
approved these changes
Feb 11, 2025
This was referenced Aug 1, 2025
This was referenced Nov 24, 2025
This was referenced Jan 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This was an interesting one to track down. Basically, when
UnpWriteDatais called with a size of0, it must callwriteStream.Writeeven ifdestUnpSizeis 0 to ensure thatSuspendedis set to false.The same condition change must be done here:
sharpcompress/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs
Line 266 in 94789ce
to make sure that the code passes over both
if (destUnpSize < 0)andif (suspended)conditions and continues below.While investigating this bug I found some other issues in the rarVM code, but I'm not sure how to test them and whether that code is even still used nowadays.
TODO: Find some example archive that shows this bug that isn't 40MB and add a test case for it.