Repository navigation
Recognize legacy TAR headers by checksum - #168
Open
ViktorBystrov72 wants to merge 1 commit into
Open
ViktorBystrov72 wants to merge 1 commit into
ViktorBystrov72 wants to merge 1 commit into
Conversation
Check a complete legacy header when the USTAR signature is absent. Validate octal checksum syntax before scanning, and accept historical signed-byte checksums alongside unsigned checksums. Fixes h2non#109. Signed-off-by: Виктор Быстров <anatema@bk.ru>
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.
Fixes #109. Related to #113.
Legacy V7 TAR archives do not have a
ustarsignature, soMatchandMatchReadercurrently returnunknownfor valid archives. Add a checksum fallback over a complete 512-byte header. It validates the octal checksum syntax before scanning the header and accepts both unsigned-byte and historical signed-byte checksums. The existing USTAR signature check remains the fast path.Tests generate archives locally and verify their header and payload with Go's
archive/tarbefore checking detection. They cover full archives, header-only buffers, non-ASCII names, signed checksums, malformed checksum fields, corruption, zero/random data, and truncated buffers. Nine V7 cases fail on the unchanged base and pass with this change.Validation on macOS arm64:
go test -count=1 ./...passed.go test -race -count=1 ./...passed.gofmt -sandgit diff --checkpassed.go vet ./...reports the existing copylock atfiletype.go:11(Types = types.Types). This also occurs on unchanged upstream with both toolchains. All other vet analyzers pass withgo vet -copylocks=false ./....Matchstayed around 2.4 µs/op. This controlled comparison is not a production-throughput estimate because the registry's map iteration order varies.This is header sniffing, not full archive validation.
MatchReaderretains its existing short-read padding behavior, addressed separately in #167. Truncation tests therefore exercise direct buffers; reader tests use full inputs.