git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] get_fetch_map(): tighten checks on dest refs

From
Junio C Hamano <gitster@pobox.com>
Date
May 4, 2012, 22:35 UTC
Message-ID
<7vsjff8ti1.fsf_-_@alter.siamese.dyndns.org>
In-Reply-To
<7vwr4r8tpm.fsf@alter.siamese.dyndns.org>

The code to check the refname we store the fetched result locally did not bother checking the first 5 bytes of it, presumably assuming that it always begin with "refs/". For a fetch refspec (or the result of applying wildcard on one), we always want the RHS to map to something inside "refs/" hierarchy, so let's spell that rule out in a more explicit way.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 remote.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/remote.c b/remote.c
index eacd8ad..0f2b1db 100644
--- a/remote.c
+++ b/remote.c
@@ -1402,8 +1402,8 @@ int get_fetch_map(const struct ref *remote_refs,
 
 	for (rmp = &ref_map; *rmp; ) {
 		if ((*rmp)->peer_ref) {
-			if (check_refname_format((*rmp)->peer_ref->name + 5,
-				REFNAME_ALLOW_ONELEVEL)) {
+			if (prefixcmp((*rmp)->peer_ref->name, "refs/") ||
+			    check_refname_format((*rmp)->peer_ref->name, 0)) {
 				struct ref *ignore = *rmp;
 				error("* Ignoring funny ref '%s' locally",
 				      (*rmp)->peer_ref->name);
-- 
1.7.10.1.500.g37b1e9a
Previous: Junio C HamanoNext: Michael Haggerty
Message 5 of 10 in “[BUG] "fetch $there +refs/*:refs/*" fails if there is a stash”
  1. Junio C HamanoMay 1, 2012
  2. Michael HaggertyMay 2, 2012
  3. Junio C HamanoMay 2, 2012
  4. fetch/push: allow refs/*:refs/*Junio C Hamano, May 4, 2012
  5. get_fetch_map(): tighten checks on dest refsJunio C Hamano, May 4, 2012
  6. Michael HaggertyMay 5, 2012
  7. Michael HaggertyMay 5, 2012
  8. Junio C HamanoMay 7, 2012
  9. Michael HaggertyMay 15, 2012
  10. Junio C HamanoMay 15, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.