Repository navigation
Conversation
…as tar
A ustar archive whose first member name starts with "MZ" matches both
the exe matcher ("MZ" at offset 0) and the tar matcher ("ustar" at
offset 257). Both are in the Archive map, so Match returned exe in some
processes and tar in others, and Archive could change from call to call.
Leave such a buffer to the more specific tar matcher, so the result no
longer depends on the map iteration order.
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.
Refs #64
A ustar archive whose first member name starts with "MZ" matches both the
exematcher ("MZ" at offset 0) and thetarmatcher ("ustar" at offset 257). Both are in theArchivemap, sofiletype.Matchreturnsexein some processes andtarin others, andfiletype.Archivecan change from one call to the next.This change adds an
Exematcher that requires the "MZ" signature and that the buffer is not a tar archive, so the buffer is always matched by the more specifictarsignature, whatever the map order. It is the same approach as #161 for deb and ar. Sorting the matchers by extension (#73) would make this pair deterministic but alwaysexe.Tests: added
TestMatchTarWithMZNameinmatch_test.go. It builds a one-member ustar archive namedMZ.txtwitharchive/tar, callsMatchandArchive100 times each and expectstar, and checks that a buffer with only "MZ" is stillexe. It fails before the change and passes after it (also with-count=30). With go1.27.4 on darwin/arm64:go test ./...gives 19 passed, 0 failed (master: 18 passed);gofmt -s -d ./is empty.go vet ./...reports the same warning before and after the change, which is already on master:filetype.go:11:13: variable declaration copies lock value to Types: sync.Map contains sync.noCopy.