iremove extra slash from request path if it is in a chroot - geomyidae - A small C-based gopherd. Err bitreich.org 70 hgit clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ URL:git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ bitreich.org 70 1Log /scm/geomyidae/log.gph bitreich.org 70 1Files /scm/geomyidae/files.gph bitreich.org 70 1Refs /scm/geomyidae/refs.gph bitreich.org 70 1Tags /scm/geomyidae/tag bitreich.org 70 1README /scm/geomyidae/file/README.gph bitreich.org 70 1LICENSE /scm/geomyidae/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit 980a398da8acca65a13936ff0792c39f3dcb0ede /scm/geomyidae/commit/980a398da8acca65a13936ff0792c39f3dcb0ede.gph bitreich.org 70 1parent 7d7fc25a935fe9a9093abe93f678fa7a9bfd6549 /scm/geomyidae/commit/7d7fc25a935fe9a9093abe93f678fa7a9bfd6549.gph bitreich.org 70 hAuthor: Hiltjo Posthuma URL:mailto:hiltjo@codemadness.org bitreich.org 70 iDate: Sat, 18 Feb 2023 12:29:29 +0100 Err bitreich.org 70 i Err bitreich.org 70 iremove extra slash from request path if it is in a chroot Err bitreich.org 70 i Err bitreich.org 70 iRemove extra slash from request path if it is in a chroot. Err bitreich.org 70 iThis is because a chroot sets base to "/", otherwise "/" at the end were Err bitreich.org 70 ialready stripped. Err bitreich.org 70 i Err bitreich.org 70 iThis also fixes the $PATH_TRANSLATED environment variable in CGI scripts. Err bitreich.org 70 i Err bitreich.org 70 iSigned-off-by: Christoph Lohmann <20h@r-36.net> Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M main.c | 5 ++++- Err bitreich.org 70 i Err bitreich.org 70 i1 file changed, 4 insertions(+), 1 deletion(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/main.c b/main.c /scm/geomyidae/file/main.c.gph bitreich.org 70 i@@ -248,7 +248,10 @@ handlerequest(int sock, char *req, int rlen, char *base, char *ohost, Err bitreich.org 70 i return; Err bitreich.org 70 i } Err bitreich.org 70 i Err bitreich.org 70 i- if (snprintf(path, sizeof(path), "%s%s", base, recvb) > sizeof(path)) { Err bitreich.org 70 i+ /* append base to request path (always starting with /), if base is a chroot don't append '/' */ Err bitreich.org 70 i+ if (snprintf(path, sizeof(path), "%s%s", Err bitreich.org 70 i+ base[0] == '/' && base[1] == '\0' ? "" : base, Err bitreich.org 70 i+ recvb) > sizeof(path)) { Err bitreich.org 70 i if (loglvl & ERRORS) { Err bitreich.org 70 i logentry(clienth, clientp, recvc, Err bitreich.org 70 i "path truncation occurred"); Err bitreich.org 70 .