| 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(-)
--- |
| @@ -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 != '/')? "/" : "", |