ref_transaction_update(): die on disallowed flags
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 5 Nov 2017 08:42:03 +0000 (09:42 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Nov 2017 01:31:07 +0000 (10:31 +0900)
Callers shouldn't be passing disallowed flags into
`ref_transaction_update()`. So instead of masking them off, treat it
as a bug if any are set.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
diff --git a/refs.c b/refs.c
index 62a7621025eba7ed39a6391caf1b1ecf511bd5ba..7c1e206e08b7febb4d0272699ee3c7fddcca481a 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -940,7 +940,8 @@ int ref_transaction_update(struct ref_transaction *transaction,
                return -1;
        }
 
-       flags &= REF_TRANSACTION_UPDATE_ALLOWED_FLAGS;
+       if (flags & ~REF_TRANSACTION_UPDATE_ALLOWED_FLAGS)
+               BUG("illegal flags 0x%x passed to ref_transaction_update()", flags);
 
        flags |= (new_oid ? REF_HAVE_NEW : 0) | (old_oid ? REF_HAVE_OLD : 0);