Skip to content

Commit

Permalink
builtin-fast-export.c: fix crash on tagged trees
Browse files Browse the repository at this point in the history
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 <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Erik Faye-Lund authored and Junio C Hamano committed Mar 30, 2009
1 parent 2d07f6d commit c0582c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions builtin-fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ static void get_tags_and_duplicates(struct object_array *pending,
case OBJ_BLOB:
handle_object(tag->object.sha1);
continue;
default:
warning("Tag points to object of unexpected type %s, skipping.",
typename(tag->object.type));
continue;
}
break;
default:
Expand Down
5 changes: 2 additions & 3 deletions t/t9301-fast-export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,8 @@ test_expect_success 'set-up a few more tags for tag export tests' '
'

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

Expand Down

0 comments on commit c0582c5

Please sign in to comment.