Skip to content

Commit ba88f8c

Browse files
committed
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
2 parents c000d91 + 40286ca commit ba88f8c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

object.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,8 @@ struct object *parse_object_with_flags(struct repository *r,
286286
return &commit->object;
287287
}
288288

289-
if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) ||
290-
(!obj && repo_has_object_file(r, oid) &&
291-
oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
289+
if ((!obj || obj->type == OBJ_BLOB) &&
290+
oid_object_info(r, oid, NULL) == OBJ_BLOB) {
292291
if (!skip_hash && stream_object_signature(r, repl) < 0) {
293292
error(_("hash mismatch %s"), oid_to_hex(oid));
294293
return NULL;

t/t6102-rev-list-unexpected-objects.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ test_expect_success 'setup unexpected non-blob tag' '
121121
tag=$(git hash-object -w --literally -t tag broken-tag)
122122
'
123123

124-
test_expect_success 'TODO (should fail!): traverse unexpected non-blob tag (lone)' '
125-
git rev-list --objects $tag
124+
test_expect_success 'traverse unexpected non-blob tag (lone)' '
125+
test_must_fail git rev-list --objects $tag
126126
'
127127

128128
test_expect_success 'traverse unexpected non-blob tag (seen)' '

0 commit comments

Comments
 (0)