| remove extra slash from request path if it is in a chroot - geomyidae - A small… | |
| git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| README | |
| LICENSE | |
| --- | |
| commit 980a398da8acca65a13936ff0792c39f3dcb0ede | |
| parent 7d7fc25a935fe9a9093abe93f678fa7a9bfd6549 | |
| Author: Hiltjo Posthuma <[email protected]> | |
| Date: Sat, 18 Feb 2023 12:29:29 +0100 | |
| remove extra slash from request path if it is in a chroot | |
| Remove extra slash from request path if it is in a chroot. | |
| This is because a chroot sets base to "/", otherwise "/" at the end were | |
| already stripped. | |
| This also fixes the $PATH_TRANSLATED environment variable in CGI scripts. | |
| Signed-off-by: Christoph Lohmann <[email protected]> | |
| Diffstat: | |
| M main.c | 5 ++++- | |
| 1 file changed, 4 insertions(+), 1 deletion(-) | |
| --- | |
| diff --git a/main.c b/main.c | |
| @@ -248,7 +248,10 @@ handlerequest(int sock, char *req, int rlen, char *base, c… | |
| return; | |
| } | |
| - if (snprintf(path, sizeof(path), "%s%s", base, recvb) > sizeof(path)) { | |
| + /* append base to request path (always starting with /), if base is a … | |
| + if (snprintf(path, sizeof(path), "%s%s", | |
| + base[0] == '/' && base[1] == '\0' ? "" : base, | |
| + recvb) > sizeof(path)) { | |
| if (loglvl & ERRORS) { | |
| logentry(clienth, clientp, recvc, | |
| "path truncation occurred"); |