path: root/fast-import.c
diff options
authorJonathan Nieder <>2012-03-10 04:07:22 (GMT)
committerJonathan Nieder <>2012-03-10 04:07:22 (GMT)
commit178e1deaae33f879ea687e85ac72455b3072b0d8 (patch)
tree649d84cda0fd2ee79be730bd3aa37764dc98c6ab /fast-import.c
parentc27e559da5b26faa31858fe6dc5492d4f605b867 (diff)
fast-import: don't allow 'ls' of path with empty components
As the fast-import manual explains: The value of <path> must be in canonical form. That is it must not: . contain an empty directory component (e.g. foo//bar is invalid), . end with a directory separator (e.g. foo/ is invalid), . start with a directory separator (e.g. /foo is invalid), Unfortunately the "ls" command accepts these invalid syntaxes and responds by declaring that the indicated path is missing. This is too subtle and causes importers to silently misbehave; better to error out so the operator knows what's happening. The C, R, and M commands already error out for such paths. Reported-by: Andrew Sayers <> Analysis-by: David Barr <> Signed-off-by: Jonathan Nieder <>
Diffstat (limited to 'fast-import.c')
1 files changed, 2 insertions, 0 deletions
diff --git a/fast-import.c b/fast-import.c
index fff285c..47f61f3 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1640,6 +1640,8 @@ static int tree_content_get(
n = slash1 - p;
n = strlen(p);
+ if (!n)
+ die("Empty path component found in input");
if (!root->tree)