Skip to content

Commit 313fb01

Browse files
mhaggergitster
authored andcommitted
resolve_ref(): do not follow incorrectly-formatted symbolic refs
Emit a warning and fail if a symbolic reference refers to an incorrectly-formatted refname. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c224ca7 commit 313fb01

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

refs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
581581
buf = buffer + 4;
582582
while (isspace(*buf))
583583
buf++;
584+
if (check_refname_format(buf, REFNAME_ALLOW_ONELEVEL)) {
585+
warning("symbolic reference in %s is formatted incorrectly",
586+
path);
587+
return NULL;
588+
}
584589
ref = strcpy(ref_buffer, buf);
585590
if (flag)
586591
*flag |= REF_ISSYMREF;

0 commit comments

Comments
 (0)