Skip to content

Fix single-entry extraction failures for solid RAR archives#1364

Draft
adamhathcock with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-nullreferenceexception-extracting-executable
Draft

Fix single-entry extraction failures for solid RAR archives#1364
adamhathcock with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-nullreferenceexception-extracting-executable

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Extracting a single file (for example mkisofs.exe) from a solid RAR could fail with runtime exceptions (NullReferenceException and related unpack-state failures) when using entry.WriteTo* APIs. This change hardens solid-entry extraction so direct entry extraction behaves correctly for these archives.

  • Solid RAR unpack state initialization

    • Ensures UnpackV1 allocates its window buffer when processing a compressed solid entry with no pre-existing window state.
    • Removes a null-window path that could crash during back-reference copy operations.
  • Targeted fallback for solid entry extraction

    • In IArchiveEntryExtensions.WriteTo / WriteToAsync, direct OpenEntryStream* extraction is still attempted first.
    • For solid entries only, known state/stream failures now retry through sequential solid-reader extraction and copy the matched entry stream to the destination.
    • Matching is done by stable entry metadata (Key, Size, IsDirectory) to avoid reference-coupling with lazy loaders.
  • Regression coverage

    • Adds sync and async tests proving a non-first entry in a solid RAR can be extracted via WriteTo / WriteToAsync.
using var archive = RarArchive.OpenArchive(archivePath);
var target = archive.Entries.Where(e => !e.IsDirectory).Skip(1).First();

using var output = new MemoryStream();
target.WriteTo(output); // now succeeds for solid RAR single-entry extraction

Copilot AI changed the title [WIP] Fix NullReferenceException when extracting executable from RAR file Fix single-entry extraction failures for solid RAR archives Jul 2, 2026
Copilot AI requested a review from adamhathcock July 2, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NullReferenceException when trying to extract an executable from a RAR file

2 participants