All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] resolve_gitlink_ref_recursive(): verify format of symbolic refs
@ 2014-06-27 11:01 Michael Haggerty
  2014-06-27 17:53 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Haggerty @ 2014-06-27 11:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Jens Lehmann, git, Michael Haggerty

When reading a symbolic ref via resolve_gitlink_ref_recursive(), check
that the reference name that is pointed at is formatted correctly,
using the same check as resolve_ref_unsafe() uses for non-gitlink
references.  This prevents bogosity like

    ref: ../../other/file

from causing problems.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
Given that symbolic references cannot be transferred via the Git
protocol, I do not expect this bug to be exploitable.

 refs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/refs.c b/refs.c
index dc45774..7da8e7d 100644
--- a/refs.c
+++ b/refs.c
@@ -1273,6 +1273,9 @@ static int resolve_gitlink_ref_recursive(struct ref_cache *refs,
 	while (isspace(*p))
 		p++;
 
+	if (check_refname_format(p, REFNAME_ALLOW_ONELEVEL))
+		return -1;
+
 	return resolve_gitlink_ref_recursive(refs, p, sha1, recursion+1);
 }
 
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-28  5:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-27 11:01 [PATCH] resolve_gitlink_ref_recursive(): verify format of symbolic refs Michael Haggerty
2014-06-27 17:53 ` Junio C Hamano
2014-06-27 17:59   ` Junio C Hamano
2014-06-28  5:34     ` Michael Haggerty

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.