diff options
| author | Junio C Hamano <gitster@pobox.com> | 2022-11-28 12:13:42 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2022-11-28 12:13:42 +0900 |
| commit | ba88f8c81dcd5968901cdc11b3ade927acc61f7e (patch) | |
| tree | 9aab34bab7db984642a20c1af35ea446ca57b6f9 | |
| parent | c000d916380bb59db69c78546928eadd076b9c7d (diff) | |
| parent | 40286ca2fa1e08c386ea7bc6b76616a3cac63ffd (diff) | |
| download | git-ba88f8c81dcd5968901cdc11b3ade927acc61f7e.tar.xz | |
Merge branch 'jk/parse-object-type-mismatch'
`parse_object()` hardening when checking for the existence of a
suspected blob object.
* jk/parse-object-type-mismatch:
parse_object(): simplify blob conditional
parse_object(): check on-disk type of suspected blob
parse_object(): drop extra "has" check before checking object type
| -rw-r--r-- | object.c | 5 | ||||
| -rwxr-xr-x | t/t6102-rev-list-unexpected-objects.sh | 4 |
2 files changed, 4 insertions, 5 deletions
@@ -286,9 +286,8 @@ struct object *parse_object_with_flags(struct repository *r, return &commit->object; } - if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) || - (!obj && repo_has_object_file(r, oid) && - oid_object_info(r, oid, NULL) == OBJ_BLOB)) { + if ((!obj || obj->type == OBJ_BLOB) && + oid_object_info(r, oid, NULL) == OBJ_BLOB) { if (!skip_hash && stream_object_signature(r, repl) < 0) { error(_("hash mismatch %s"), oid_to_hex(oid)); return NULL; diff --git a/t/t6102-rev-list-unexpected-objects.sh b/t/t6102-rev-list-unexpected-objects.sh index 4a9a4436e2..9350b5fd2c 100755 --- a/t/t6102-rev-list-unexpected-objects.sh +++ b/t/t6102-rev-list-unexpected-objects.sh @@ -121,8 +121,8 @@ test_expect_success 'setup unexpected non-blob tag' ' tag=$(git hash-object -w --literally -t tag broken-tag) ' -test_expect_success 'TODO (should fail!): traverse unexpected non-blob tag (lone)' ' - git rev-list --objects $tag +test_expect_success 'traverse unexpected non-blob tag (lone)' ' + test_must_fail git rev-list --objects $tag ' test_expect_success 'traverse unexpected non-blob tag (seen)' ' |
