summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Michael Haggerty <mhagger@alum.mit.edu>2015-02-17 18:00:19 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-02-17 11:24:48 -0800
commitf04c5b5522214cd48b39399d1d26b07848fd0e52 (patch)
tree732a685bb72963708b63001abd6fb57eda320f09
parentcommit: avoid race when creating orphan commits (diff)
downloadtgif-f04c5b5522214cd48b39399d1d26b07848fd0e52.tar.xz
ref_transaction_create(): check that new_sha1 is valid
Creating a reference requires a new_sha1 that is not NULL and not null_sha1. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index e3c4ab5fd5..b9cf284f31 100644
--- a/refs.c
+++ b/refs.c
@@ -3690,6 +3690,8 @@ int ref_transaction_create(struct ref_transaction *transaction,
unsigned int flags, const char *msg,
struct strbuf *err)
{
+ if (!new_sha1 || is_null_sha1(new_sha1))
+ die("BUG: create called without valid new_sha1");
return ref_transaction_update(transaction, refname, new_sha1,
null_sha1, flags, msg, err);
}