[PR #894] Fix condition in rar v3 code #1320

Open
opened 2026-01-29 22:19:57 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/894

State: closed
Merged: Yes


This was an interesting one to track down. Basically, when UnpWriteData is called with a size of 0, it must call writeStream.Write even if destUnpSize is 0 to ensure that Suspended is set to false.
The same condition change must be done here: 94789ce455/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs (L266)
to make sure that the code passes over both if (destUnpSize < 0) and if (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.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/894 **State:** closed **Merged:** Yes --- - closes #890 This was an interesting one to track down. Basically, when `UnpWriteData` is called with a size of `0`, it must call `writeStream.Write` even if `destUnpSize` is 0 to ensure that `Suspended` is set to false. The same condition change must be done here: https://github.com/adamhathcock/sharpcompress/blob/94789ce455cf88cbe0636abc0071c1c03d4a2ebf/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs#L266 to make sure that the code passes over both `if (destUnpSize < 0)` and `if (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.
claunia added the pull-request label 2026-01-29 22:19:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1320