From a77c03fcaf3eedc84f35d1a38e45701d83a445b0 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Tue, 11 Feb 2025 11:03:56 +0100 Subject: [PATCH] add comment and change the same code in new Unpack50 --- src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs | 2 ++ .../Compressors/Rar/UnpackV2017/Unpack.unpack50_cpp.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs index 732c57e8..c4e6d108 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs @@ -713,6 +713,8 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable private void UnpWriteData(byte[] data, int offset, int size) { + // allow destUnpSize == 0 here to ensure that 0 size writes + // go through RarStream's Write so that Suspended is set correctly if (destUnpSize < 0) { return; diff --git a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack50_cpp.cs b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack50_cpp.cs index 143e3d31..a2e49686 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack50_cpp.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack50_cpp.cs @@ -655,7 +655,9 @@ internal partial class Unpack private void UnpWriteData(byte[] Data, size_t offset, size_t Size) { - if (WrittenFileSize >= DestUnpSize) + // allow WrittenFileSize == DestUnpSize here to ensure that 0 size writes + // go through RarStream's Write so that Suspended is set correctly + if (WrittenFileSize > DestUnpSize) { return; }