geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit 646c0c9ac1c8944393c3640c63ffefd6f400c2a5
parent 2a482d9af02b09bc8a770c4e08be577264d473c5
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 22 Jul 2023 17:14:26 +0200

Move .. handling to a more efficient position.

Diffstat:
Mmain.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/main.c b/main.c @@ -187,6 +187,12 @@ handlerequest(int sock, char *req, int rlen, char *base, char *ohost, if (c) c[0] = '\0'; + /* Do not allow requests including "..". */ + if (strstr(recvb, "..")) { + dprintf(sock, "%s", selinval); + return; + } + sear = strchr(recvb, '\t'); if (sear != NULL) { *sear++ = '\0'; @@ -245,12 +251,6 @@ handlerequest(int sock, char *req, int rlen, char *base, char *ohost, } printf("traverse = %s\n", traverse); - /* Do not allow requests including "..". */ - if (strstr(recvb, "..")) { - dprintf(sock, "%s", selinval); - return; - } - printf("recvb = %s\n", recvb); if (snprintf(path, sizeof(path), "%s%s%s", base, (*recvb != '/')? "/" : "",