Fix tar archive enumeration after fully reading entry streams#1324
Closed
Copilot wants to merge 182 commits into
Closed
Fix tar archive enumeration after fully reading entry streams#1324Copilot wants to merge 182 commits into
Copilot wants to merge 182 commits into
Conversation
…atch interface name Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Rename IWriteableArchiveFactory.cs to IWritableArchiveFactory.cs
Some API clean up from GPT 5.4
…path 1. Fix off-by-one in Update(BLAKE2SP): pos was masked with 448 (64×7) instead of 511 (64×8−1), causing incorrect leaf assignment when update chunks are not multiples of 64 bytes. This produced wrong hashes whenever streaming reads didn't align to 64-byte boundaries. 2. Fix double-finalization when Read() is called again after returning 0. Final() was called unconditionally on each EOF read, re-running compression on an already-finalized state and corrupting the hash. EnsureHash() guards with a null-check and is idempotent; both sync and async Read paths share the fix. _blake2sp is set to null after finalization so any erroneous post-final calls fail fast rather than silently corrupting state. 3. Fix false-positive CRC check when stream is not fully drained. _hash was initialized to fileHeader.FileCrc in the constructor, so GetCrc() returned the expected CRC rather than the computed one if the stream was abandoned early. The check would then compare the expected hash against itself and always succeed, silently accepting a corrupt or incomplete file. _hash is now null until the stream is fully read; GetCrc() throws if called early rather than returning a misleading value. Additional changes: - Compress: stackalloc m/v arrays instead of heap; LE fast path via MemoryMarshal.Cast replaces 16 BitConverter.ToUInt32 calls per block - Final(BLAKE2S): write directly to Span<byte>, eliminating MemoryStream and BitConverter.GetBytes allocations; 8 leaf digests now stackalloc'd - Inner classes and fields: private, sealed, readonly where applicable
Release to master
Fix three BLAKE2sp correctness bugs and eliminate allocations in hot path
# Conflicts: # src/SharpCompress/packages.lock.json
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… in PooledMemoryStream Agent-Logs-Url: https://github.com/adamhathcock/sharpcompress/sessions/1f2c3c48-1112-43f1-82ce-efb157fbe0d5 Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
add AOT smoke and missing tests
|
@adamhathcock any chance we can get this merged? |
…ve-disposeasync Close writable entry streams during async archive disposal
…reporting Restore `WriteToDirectoryAsync` progress callbacks for solid 7z archives
Owner
|
@copilot add a TarReader and TarReaderAsync and TarArchiveAsync style tests to this PR |
Contributor
Author
Added matching regression coverage in |
…ive-missing-entries # Conflicts: # tests/SharpCompress.Test/Tar/TarArchiveAsyncTests.cs
Try to fix global.json to avoid churn in locks
…ive-missing-entries
Owner
|
Closing in favor of #1342 This fix got lost. I'll put it out shortly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TarArchive.OpenArchive(stream)could stop yielding entries when callers iteratedarchive.Entries, fully read an entry viaOpenEntryStream(), and moved on before disposing that stream. In practice, the shared tar stream could remain parked on entry padding, so the next header read started from the wrong offset.Behavior change
TarReadOnlySubStreamto advance to the next tar header as soon as the current entry has been fully consumed.Why this matters
IArchiveusage pattern shown in the issue, where each file is read to EOF during iteration.Regression coverage
archive.Entries,