[PR #638] Rar2 fix with new unit tests that fail on previous build. #1136

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

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

State: closed
Merged: Yes


I noticed files within WinRar2.8 archives were not decompressing properly. Some were fine, others were fine at the start then corrupt half way through the file. I was able to reproduce this behaviour by using WinRar2.8 to create SharpCompress test archives.

After debugging the streams to confirm the RAR compressed parts were being extracted correctly, I noticed it was the decoding that was failing. I stumbled upon RarEntry.IsRarV3 property and added FileHeader.CompressionAlgorithm == 20 || FileHeader.CompressionAlgorithm == 26 to the logic. This forces it to use the UnpackV1 code rather than UnpackV2017. This fixes it.

This PR also includes the UnitTests and Archives. Hopefully it will be useful

I think it fixes this issue also: https://github.com/adamhathcock/sharpcompress/issues/619

Thanks.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/638 **State:** closed **Merged:** Yes --- I noticed files within WinRar2.8 archives were not decompressing properly. Some were fine, others were fine at the start then corrupt half way through the file. I was able to reproduce this behaviour by using WinRar2.8 to create SharpCompress test archives. After debugging the streams to confirm the RAR compressed parts were being extracted correctly, I noticed it was the decoding that was failing. I stumbled upon `RarEntry.IsRarV3` property and added `FileHeader.CompressionAlgorithm == 20 || FileHeader.CompressionAlgorithm == 26` to the logic. This forces it to use the UnpackV1 code rather than UnpackV2017. This fixes it. This PR also includes the UnitTests and Archives. Hopefully it will be useful I think it fixes this issue also: https://github.com/adamhathcock/sharpcompress/issues/619 Thanks.
claunia added the pull-request label 2026-01-29 22:19:09 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1136