Skip to content

Commit 426193c

Browse files
kusmagitster
authored andcommitted
builtin-fast-export.c: fix crash on tagged trees
If a tag object points to a tree (or another unhandled type), the commit- pointer is left uninitialized and later dereferenced. This patch adds a default case to the switch that issues a warning and skips the object. Signed-off-by: Erik Faye-Lund <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38124d8 commit 426193c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

builtin-fast-export.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ static void get_tags_and_duplicates(struct object_array *pending,
375375
case OBJ_BLOB:
376376
handle_object(tag->object.sha1);
377377
continue;
378+
default:
379+
warning("Tag points to object of unexpected type %s, skipping.",
380+
typename(tag->object.type));
381+
continue;
378382
}
379383
break;
380384
default:

t/t9301-fast-export.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,8 @@ test_expect_success 'set-up a few more tags for tag export tests' '
269269
'
270270

271271
# NEEDSWORK: not just check return status, but validate the output
272-
# two tests commented out due to crash and thus unreliable return code
273-
test_expect_failure 'tree_tag' 'git fast-export tree_tag'
274-
test_expect_failure 'tree_tag-obj' 'git fast-export tree_tag-obj'
272+
test_expect_success 'tree_tag' 'git fast-export tree_tag'
273+
test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj'
275274
test_expect_failure 'tag-obj_tag' 'git fast-export tag-obj_tag'
276275
test_expect_failure 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
277276

0 commit comments

Comments
 (0)