From: Junio C Hamano Date: Sun, 10 Sep 2017 08:28:03 +0000 (+0900) Subject: Merge branch 'mh/notes-cleanup' into next X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cb1d7255048d2bbea5580cee7d7d21bcae87427a?hp=-c Merge branch 'mh/notes-cleanup' into next Code clean-up. * mh/notes-cleanup: load_subtree(): check that `prefix_len` is in the expected range --- cb1d7255048d2bbea5580cee7d7d21bcae87427a diff --combined notes.c index 7f5bfa19c7,27d232f294..5c62862574 --- a/notes.c +++ b/notes.c @@@ -411,13 -411,16 +411,16 @@@ static void load_subtree(struct notes_t struct tree_desc desc; struct name_entry entry; - buf = fill_tree_descriptor(&desc, subtree->val_oid.hash); + buf = fill_tree_descriptor(&desc, &subtree->val_oid); if (!buf) die("Could not read %s for notes-index", oid_to_hex(&subtree->val_oid)); prefix_len = subtree->key_oid.hash[KEY_INDEX]; - assert(prefix_len * 2 >= n); + if (prefix_len >= GIT_SHA1_RAWSZ) + BUG("prefix_len (%"PRIuMAX") is out of range", (uintmax_t)prefix_len); + if (prefix_len * 2 < n) + BUG("prefix_len (%"PRIuMAX") is too small", (uintmax_t)prefix_len); memcpy(object_oid.hash, subtree->key_oid.hash, prefix_len); while (tree_entry(&desc, &entry)) { unsigned char type; @@@ -1022,7 -1025,7 +1025,7 @@@ void init_notes(struct notes_tree *t, c t->dirty = 0; if (flags & NOTES_INIT_EMPTY || !notes_ref || - get_sha1_treeish(notes_ref, object_oid.hash)) + get_oid_treeish(notes_ref, &object_oid)) return; if (flags & NOTES_INIT_WRITABLE && read_ref(notes_ref, object_oid.hash)) die("Cannot use notes ref %s", notes_ref);