diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 1e7ab67f6e5f13..3e7ec1f11987d4 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1468,6 +1468,8 @@ static int tree_content_set(
root->tree = t = grow_tree_content(t, t->entry_count);
e = new_tree_entry();
e->name = to_atom(p, n);
+ if (is_dot_or_dotdot(e->name->str_dat))
+ die("path %s contains invalid component", p);
e->versions[0].mode = 0;
oidclr(&e->versions[0].oid, the_repository->hash_algo);
t->entries[t->entry_count++] = e;
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 3b3c371740a392..5a5127fffa7d82 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -522,6 +522,26 @@ test_expect_success 'B: fail on invalid committer (5)' '
test_must_fail git fast-import input <<-INPUT_END &&
+ blob
+ mark :1
+ data < $GIT_COMMITTER_DATE
+ data <