Pool RAR Huffman scratch buffers and validate async checksums

Reuse unpacker-owned pooled scratch arrays for async RAR5 and RAR2 Huffman tables, preserving alphabet bounds and zeroed history tails. Match async Archive CRC32/BLAKE2sp verification to the synchronous path and dispose entry streams when initialization fails.

Add regression tests and profiling documentation showing approximately 3.13 MiB fewer managed allocations per 200 MiB extraction. Keep this change based directly on master without unrelated branch commits.

Validation: 2,983 .NET 10 Release tests passed, all six library targets built, net48 tests compiled, and formatting checks passed.
This commit is contained in:
Adam Hathcock
2026-10-19 14:10:30 +01:00
parent 0fbf36d602
commit 81879e9de4
9 changed files with 474 additions and 21 deletions

View File

@@ -101,6 +101,15 @@ The stream overloads of `DetectArchive` and `InspectArchive` preserve the suppli
| `ZipDataDescriptorEntryCount` | `Zip.HasEntriesWithDeferredSizes` |
| `SolidStreamCount` | `SolidStreamCount` |
### RAR Entry Integrity
RAR Archive and Reader entry streams validate CRC32 (or RAR5 BLAKE2sp when
present) on both synchronous and asynchronous extraction paths. Drain an entry
stream to the end to perform validation; a mismatch throws
`InvalidFormatException`. Disposing a partially read stream does not validate
the unread payload. Encrypted entries retain the existing checksum-checking
limitations; this does not add authentication for encrypted RAR data.
### RAR5 Archive Comments
`SharpCompress.Common.Rar.RarVolume.Comment` exposes UTF-8 archive comments, including encrypted comments when `ReaderOptions.Password` is supplied. Comments are loaded while entries are enumerated; the property can be `null` before enumeration or when no comment is present.