summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorDavid Turner <dturner@twopensource.com>2015-07-15 18:05:28 -0400
committerJunio C Hamano <gitster@pobox.com>2015-08-11 15:52:20 -0700
commit2c3aed1381f22494bc06fd66dec8292a296db10f (patch)
tree049b6b12c404c8b6cf49550afc5b364c49fae8a8 /refs.c
parentd96a53996b6c02b96a9a2b4eed9eac4e9d661a38 (diff)
downloadgit-2c3aed1381f22494bc06fd66dec8292a296db10f.tar.gz
pseudoref: check return values from read_ref()dt/refs-pseudo
These codepaths attempt to compare the "expected" current value with the actual current value, but did not check if we successfully read the current value before comparison. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index 522b19b539..1db3654b8e 100644
--- a/refs.c
+++ b/refs.c
@@ -2868,7 +2868,9 @@ static int write_pseudoref(const char *pseudoref, const unsigned char *sha1,
if (old_sha1) {
unsigned char actual_old_sha1[20];
- read_ref(pseudoref, actual_old_sha1);
+
+ if (read_ref(pseudoref, actual_old_sha1))
+ die("could not read ref '%s'", pseudoref);
if (hashcmp(actual_old_sha1, old_sha1)) {
strbuf_addf(err, "Unexpected sha1 when writing %s", pseudoref);
rollback_lock_file(&lock);
@@ -2904,7 +2906,8 @@ static int delete_pseudoref(const char *pseudoref, const unsigned char *old_sha1
LOCK_DIE_ON_ERROR);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"), filename);
- read_ref(pseudoref, actual_old_sha1);
+ if (read_ref(pseudoref, actual_old_sha1))
+ die("could not read ref '%s'", pseudoref);
if (hashcmp(actual_old_sha1, old_sha1)) {
warning("Unexpected sha1 when deleting %s", pseudoref);
rollback_lock_file(&lock);