summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-29 00:57:07 -0800
committerJunio C Hamano <junkio@cox.net>2007-01-29 00:57:07 -0800
commita2f9fe92ebfdf9b5c458642fa0bf32b17433c6c1 (patch)
treed1484466557729e27ba4dda475dd8c6a2e918f2c /refs.c
parentdf391b192d285646fe80ca4d3cfe3c0a3beb5989 (diff)
downloadgit-a2f9fe92ebfdf9b5c458642fa0bf32b17433c6c1.tar.gz
lock_any_ref_for_update(): do not accept malformatted refs.
We used to use lock_any_ref_for_update() because the command needs to also update HEAD (which is not under refs/, so lock_ref_sha1() cannot be used). The function however did not check for refs with illegal characters in them. Use check_ref_format() to catch malformed refs. For this check, we specifically do not want to say having less than two levels in the name is illegal to allow HEAD (and perhaps other special refs in the future). Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index 12e46b8bbe..3db444cad2 100644
--- a/refs.c
+++ b/refs.c
@@ -710,6 +710,8 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1)
{
+ if (check_ref_format(ref) == -1)
+ return NULL;
return lock_ref_sha1_basic(ref, old_sha1, NULL);
}