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 <jrnieder@gmail.com> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tay Ray Chuan committed
Nov 25, 2010 at 16:21 UTC
dfc2dcd9acf95794788f9471028485c2d2cc78ef
1 file changed
+10
-2
http-push.c
+10
-2
@@ -1116,8 +1116,16 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
1116
}
1117
}
1118
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
+ }
1129
}
1130
} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
1131
ls->dentry_flags |= IS_DIR;