Simon 'corecode' Schubert <corecode@xxxxxxxxxxxx> writes: > Signed-off-by: Simon 'corecode' Schubert <corecode@xxxxxxxxxxxx> > ... > diff --git a/git-clone.sh b/git-clone.sh > index ced7dfb..b3c6fa4 100755 > --- a/git-clone.sh > +++ b/git-clone.sh > @@ -66,48 +66,6 @@ Perhaps git-update-server-info needs to be run there?" > ... > -open FH, "<", "$git_dir/CLONE_HEAD"; > -while (<FH>) { > - my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/; > - next if ($name =~ /\^\173/); > - if ($name eq "HEAD") { > ... Thanks. I like the general direction, but not quite. You exposed one outstanding bug, which is a hint about what is not quite right with your patch. -- >8 -- [PATCH] update-ref: 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@xxxxxxx> --- diff --git a/builtin-update-ref.c b/builtin-update-ref.c index 1461937..5ee960b 100644 --- a/builtin-update-ref.c +++ b/builtin-update-ref.c @@ -61,10 +61,8 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL); if (!lock) - return 1; + die("%s: cannot lock the ref", refname); if (write_ref_sha1(lock, sha1, msg) < 0) - return 1; - - /* write_ref_sha1 always unlocks the ref, no need to do it explicitly */ + die("%s: cannot update the ref", refname); return 0; } diff --git a/refs.c b/refs.c index 12e46b8..3db444c 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); } - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html