From c7902ea5b546b3d99bd01d3e1bd63b2e1b6332b0 Mon Sep 17 00:00:00 2001
From: Lorenz Stechauner <lorenz.stechauner@necronda.net>
Date: Fri, 18 Dec 2020 22:39:18 +0100
Subject: [PATCH] Added dir mode in client

---
 src/client.c | 5 +++--
 src/uri.c    | 1 -
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/client.c b/src/client.c
index f311f89..0047ce1 100644
--- a/src/client.c
+++ b/src/client.c
@@ -37,7 +37,7 @@ int client_websocket_handler() {
 
 int client_request_handler(sock *client, int req_num) {
     struct timespec begin, end;
-    int ret, client_keep_alive;
+    int ret, client_keep_alive, dir_mode;
     char buf[1024];
     char msg_buf[4096];
     char msg_pre_buf[4096];
@@ -102,8 +102,9 @@ int client_request_handler(sock *client, int req_num) {
     print(BLD_STR "%s %s" CLR_STR, req.method, req.uri);
 
     webroot = get_webroot(host);
+    dir_mode = URI_DIR_MODE_FORBIDDEN;
     http_uri uri;
-    ret = uri_init(&uri, webroot, req.uri, URI_DIR_MODE_INFO);
+    ret = uri_init(&uri, webroot, req.uri, dir_mode);
     if (ret != 0) {
         if (ret == 1) {
             sprintf(err_msg, "Invalid URI: has to start with slash.");
diff --git a/src/uri.c b/src/uri.c
index 12ef631..22dd2a3 100644
--- a/src/uri.c
+++ b/src/uri.c
@@ -61,7 +61,6 @@ int uri_init(http_uri *uri, const char *webroot, const char *uri_str, int dir_mo
     uri->req_path = malloc(size);
     url_decode(uri_str, uri->req_path, &size);
     if (strstr(uri->req_path, "/../") != NULL || strstr(uri->req_path, "/./") != NULL) {
-        if (uri->query != NULL) free(uri->query);
         return 2;
     }