]> git.ipfire.org Git - thirdparty/git.git/blobdiff - http-backend.c
http-backend: Protect GIT_PROJECT_ROOT from /../ requests
[thirdparty/git.git] / http-backend.c
index 646e9108bddbd538f04fc01129214aa8615d5e5a..f8ea9d7faa0494375d3d5413e91869d74252d649 100644 (file)
@@ -559,7 +559,13 @@ static char* getdir(void)
        if (root && *root) {
                if (!pathinfo || !*pathinfo)
                        die("GIT_PROJECT_ROOT is set but PATH_INFO is not");
+               if (daemon_avoid_alias(pathinfo))
+                       die("'%s': aliased", pathinfo);
                strbuf_addstr(&buf, root);
+               if (buf.buf[buf.len - 1] != '/')
+                       strbuf_addch(&buf, '/');
+               if (pathinfo[0] == '/')
+                       pathinfo++;
                strbuf_addstr(&buf, pathinfo);
                return strbuf_detach(&buf, NULL);
        } else if (path && *path) {