summaryrefslogtreecommitdiff
path: root/vcs-svn
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2010-11-19 18:53:34 -0600
committerJunio C Hamano <gitster@pobox.com>2010-11-24 14:52:51 -0800
commitc7dbf35e91cffbc326078d0c0470662f6422150d (patch)
treef1894b4a1b41af1730d3a3e018a6abfc9d501403 /vcs-svn
parent414e569e453a49171b1f3db613f88378324104e8 (diff)
downloadgit-c7dbf35e91cffbc326078d0c0470662f6422150d.tar.gz
vcs-svn: More dump format sanity checks
Node-action: change is not appropriate when switching between file and directory or adding a new file. Current svn-fe silently accepts such nodes and the resulting tree has missing files in the "changed when meant to add" case. Node-action: add requires some content (text or directory); there is no such thing as an "intent to add" node in svn dumps. Current svn-fe accepts such contentless adds but produces an invalid fast-import stream that refers to nonexistent mark :0 in response. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'vcs-svn')
-rw-r--r--vcs-svn/svndump.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/vcs-svn/svndump.c b/vcs-svn/svndump.c
index 0af8ac6807..ab4ccfc55f 100644
--- a/vcs-svn/svndump.c
+++ b/vcs-svn/svndump.c
@@ -181,12 +181,22 @@ static void handle_node(void)
if (mark && type == REPO_MODE_DIR)
die("invalid dump: directories cannot have text attached");
- if (node_ctx.action == NODEACT_CHANGE)
- node_ctx.type = repo_modify_path(node_ctx.dst, 0, mark);
- else if (node_ctx.action == NODEACT_ADD)
+ if (node_ctx.action == NODEACT_CHANGE) {
+ uint32_t mode = repo_modify_path(node_ctx.dst, 0, mark);
+ if (!mode)
+ die("invalid dump: path to be modified is missing");
+ if (mode == REPO_MODE_DIR && type != REPO_MODE_DIR)
+ die("invalid dump: cannot modify a directory into a file");
+ if (mode != REPO_MODE_DIR && type == REPO_MODE_DIR)
+ die("invalid dump: cannot modify a file into a directory");
+ node_ctx.type = mode;
+ } else if (node_ctx.action == NODEACT_ADD) {
+ if (!mark && type != REPO_MODE_DIR)
+ die("invalid dump: adds node without text");
repo_add(node_ctx.dst, type, mark);
- else
+ } else {
die("invalid dump: Node-path block lacks Node-action");
+ }
if (have_props) {
const uint32_t old_mode = node_ctx.type;