Skip to content

Commit dfc2dcd

Browse files
rctaygitster
authored andcommitted
http-push: check path length before using it
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 <[email protected]> Signed-off-by: Tay Ray Chuan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0fdadc5 commit dfc2dcd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

http-push.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,8 +1116,16 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
11161116
}
11171117
}
11181118
if (path) {
1119-
path += repo->path_len;
1120-
ls->dentry_name = xstrdup(path);
1119+
const char *url = repo->url;
1120+
if (repo->path)
1121+
url = repo->path;
1122+
if (strncmp(path, url, repo->path_len))
1123+
error("Parsed path '%s' does not match url: '%s'\n",
1124+
path, url);
1125+
else {
1126+
path += repo->path_len;
1127+
ls->dentry_name = xstrdup(path);
1128+
}
11211129
}
11221130
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
11231131
ls->dentry_flags |= IS_DIR;

0 commit comments

Comments
 (0)