Repository navigation
Stop copying a walked file's sniff bytes twice - #55
Merged
Merged
Conversation
A walked file whose name gives no extension is sniffed before it is staged. The sniff reads its first 16 bytes from a generator of its own, and the copy then asks the walker for the file from offset 0, so passing those bytes to the writer put them in the copy twice. The copy was 16 bytes longer than the file on the volume and its recorded md5/sha described the copy, so two identical files on the evidence came out with different hashes and neither matched the volume. Size stayed right, nothing errored, and images still decoded. Named extensions were never affected: they skip the sniff, which is why the existing staging test passed. Zip members re-open for the copy and tar members are copied through the handle the sniff read from, so both are correct as they stand. Co-Authored-By: Claude Opus 5 <[email protected]>
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.
A file walked out of an acquisition with no extension in its name is sniffed before it is copied into the case, and the sniff bytes were being written into the copy a second time.
Named extensions skip the sniff and were never affected, which is why the existing staging test passed. Zip and tar are correct as they are: a zip member re-opens for the copy, and a tar member is copied through the same handle the sniff read from.
Two tests, both red before the change: an extension-less file copies out byte for byte, and two identical files on one volume hash alike.
🤖 Generated with Claude Code