Repository navigation
refspec: guard the wildcard check against an empty source - #7499
Open
arpitjain099 wants to merge 1 commit into
Open
arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
git_refspec_is_wildcard reads spec->src[strlen(spec->src) - 1]. An empty left hand side is accepted on a fetch refspec, so src can be "" and the index is then (size_t)-1, which reads one byte before the allocation that git_refspec__parse made. AddressSanitizer reports it as a heap buffer over-read on the path from git_remote_fetch through git_remote_write_fetchhead. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This branch has not been deployed
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.
git_refspec_is_wildcarddecides whether a refspec is a pattern by readingspec->src[strlen(spec->src) - 1]. An empty left hand side is accepted on a fetch refspec, theparser's own comment being "empty is allowed; it means HEAD", and the suite already asserts that
:refs/remotes/frotz/HEAD-to-meis valid. Sosrccan be"", the index is then(size_t)-1,and AddressSanitizer reports a one byte read before the
git__strndupallocation thatgit_refspec__parsemade.It is reachable from
git_remote_fetch. With a refspec of:refs/remotes/origin/head-to-meanddownload_tagsset to all,update_tips_for_speccollects the remote tag heads andgit_remote_write_fetchheadthen asks whether the spec is a wildcard. The parser guards theequivalent look at the lhs with
1 <= llenbefore scanning for a*, so the helper should do thesame.
The added test hits the over-read under ASan without the change and passes with it.
Prepared with AI assistance.