| Move .. handling to a more efficient position. - geomyidae - A small C-based go… | |
| git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri… | |
| Log | |
| Files | |
| Refs | |
| Tags | |
| README | |
| LICENSE | |
| --- | |
| commit 646c0c9ac1c8944393c3640c63ffefd6f400c2a5 | |
| parent 2a482d9af02b09bc8a770c4e08be577264d473c5 | |
| Author: Christoph Lohmann <[email protected]> | |
| Date: Sat, 22 Jul 2023 17:14:26 +0200 | |
| Move .. handling to a more efficient position. | |
| Diffstat: | |
| M main.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, c… | |
| 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, c… | |
| } | |
| 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 != '/')? "/" : "", |