Skip to content

Commit

Permalink
http-push: check path length before using it
Browse files Browse the repository at this point in the history
We use path_len to skip the base url/path, but we do not know for sure
if path does indeed contain the base url/path. Check if this is so.

Helped-by: Johnathan Nieder <jrnieder@gmail.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Tay Ray Chuan authored and Junio C Hamano committed Nov 26, 2010
1 parent 0fdadc5 commit dfc2dcd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,8 +1116,16 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
}
}
if (path) {
path += repo->path_len;
ls->dentry_name = xstrdup(path);
const char *url = repo->url;
if (repo->path)
url = repo->path;
if (strncmp(path, url, repo->path_len))
error("Parsed path '%s' does not match url: '%s'\n",
path, url);
else {
path += repo->path_len;
ls->dentry_name = xstrdup(path);
}
}
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
ls->dentry_flags |= IS_DIR;
Expand Down

0 comments on commit dfc2dcd

Please sign in to comment.