From 2109643ec0f038c6129cbdb7a7f200e50f696015 Mon Sep 17 00:00:00 2001 From: IngBertolini Date: Thu, 29 Sep 2022 17:23:06 +0200 Subject: [PATCH 1/4] Update RarVolume.cs --- src/SharpCompress/Common/Rar/RarVolume.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/SharpCompress/Common/Rar/RarVolume.cs b/src/SharpCompress/Common/Rar/RarVolume.cs index 0546e1f1..148b1dd9 100644 --- a/src/SharpCompress/Common/Rar/RarVolume.cs +++ b/src/SharpCompress/Common/Rar/RarVolume.cs @@ -57,6 +57,18 @@ internal IEnumerable GetVolumeFileParts() yield return CreateFilePart(lastMarkHeader!, fh); } break; + case HeaderType.Service: + { + var fh = (FileHeader)header; + if (fh.FileName == "CMT") + { + var part = CreateFilePart(lastMarkHeader!, fh); + var buffer = new byte[fh.CompressedSize]; + part.GetCompressedStream().Read(buffer, 0, buffer.Length); + Comment = System.Text.Encoding.UTF8.GetString(buffer); + } + } + break; } } } @@ -145,5 +157,7 @@ public int MaxVersion return 1; } } + + public string? Comment { get; internal set; } } } From 1fc28f8cd123399ee8d6eed136a01b2b91f6846a Mon Sep 17 00:00:00 2001 From: IngBertolini Date: Thu, 29 Sep 2022 17:42:43 +0200 Subject: [PATCH 2/4] Update RarVolume.cs --- src/SharpCompress/Common/Rar/RarVolume.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SharpCompress/Common/Rar/RarVolume.cs b/src/SharpCompress/Common/Rar/RarVolume.cs index 148b1dd9..cca91ddd 100644 --- a/src/SharpCompress/Common/Rar/RarVolume.cs +++ b/src/SharpCompress/Common/Rar/RarVolume.cs @@ -63,7 +63,7 @@ internal IEnumerable GetVolumeFileParts() if (fh.FileName == "CMT") { var part = CreateFilePart(lastMarkHeader!, fh); - var buffer = new byte[fh.CompressedSize]; + var buffer = new byte[fh.CompressedSize - 1]; part.GetCompressedStream().Read(buffer, 0, buffer.Length); Comment = System.Text.Encoding.UTF8.GetString(buffer); } From cac9366c868f8c5360a65d2914ebec389120c652 Mon Sep 17 00:00:00 2001 From: IngBertolini Date: Thu, 29 Sep 2022 17:44:15 +0200 Subject: [PATCH 3/4] Update RarVolume.cs --- src/SharpCompress/Common/Rar/RarVolume.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SharpCompress/Common/Rar/RarVolume.cs b/src/SharpCompress/Common/Rar/RarVolume.cs index cca91ddd..148b1dd9 100644 --- a/src/SharpCompress/Common/Rar/RarVolume.cs +++ b/src/SharpCompress/Common/Rar/RarVolume.cs @@ -63,7 +63,7 @@ internal IEnumerable GetVolumeFileParts() if (fh.FileName == "CMT") { var part = CreateFilePart(lastMarkHeader!, fh); - var buffer = new byte[fh.CompressedSize - 1]; + var buffer = new byte[fh.CompressedSize]; part.GetCompressedStream().Read(buffer, 0, buffer.Length); Comment = System.Text.Encoding.UTF8.GetString(buffer); } From c37ea5c8905eea9b7379a33a1075c9031226c1b3 Mon Sep 17 00:00:00 2001 From: IngBertolini Date: Thu, 29 Sep 2022 18:14:56 +0200 Subject: [PATCH 4/4] Forgot to consider the zero termination --- src/SharpCompress/Common/Rar/RarVolume.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SharpCompress/Common/Rar/RarVolume.cs b/src/SharpCompress/Common/Rar/RarVolume.cs index 148b1dd9..4efbdd92 100644 --- a/src/SharpCompress/Common/Rar/RarVolume.cs +++ b/src/SharpCompress/Common/Rar/RarVolume.cs @@ -65,7 +65,7 @@ internal IEnumerable GetVolumeFileParts() var part = CreateFilePart(lastMarkHeader!, fh); var buffer = new byte[fh.CompressedSize]; part.GetCompressedStream().Read(buffer, 0, buffer.Length); - Comment = System.Text.Encoding.UTF8.GetString(buffer); + Comment = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length - 1); } } break;