summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarmanyaah Malhotra <karmanyaahm@gmail.com>2021-06-21 03:53:06 -0400
committerDrew DeVault <sir@cmpwn.com>2021-06-21 08:42:29 -0400
commit32854b79c73b278bf33eb5123abf1c36abdc7c01 (patch)
treee65ad12142494d21fe4d0751d382a3f63db65b7f /src
parent9f2481dcdf60387e57cfe357bc8d04997c967e57 (diff)
downloadgmnisrv-32854b79c73b278bf33eb5123abf1c36abdc7c01.tar.gz
gmnisrv-32854b79c73b278bf33eb5123abf1c36abdc7c01.tar.xz
gmnisrv-32854b79c73b278bf33eb5123abf1c36abdc7c01.zip
Check index before serving autoindex
if a directory is being served.
Diffstat (limited to 'src')
-rw-r--r--src/serve.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/serve.c b/src/serve.c
index 6ad7934..bcbef5c 100644
--- a/src/serve.c
+++ b/src/serve.c
@@ -526,15 +526,16 @@ serve_request(struct gmnisrv_client *client)
}
if (S_ISDIR(st.st_mode)) {
- if (route->autoindex) {
- serve_autoindex(client, real_path);
- free(url_path);
- return;
- } else {
+ strcpy(temp_path, real_path);
strncat(real_path,
route->index ? route->index : "index.gmi",
sizeof(real_path) - 1);
if (stat(real_path, &st) != 0) {
+ if (route->autoindex) {
+ serve_autoindex(client, temp_path);
+ free(url_path);
+ return;
+ }
server_error("CGI path %s has no index",
client_path);
client_submit_response(client,
@@ -542,7 +543,6 @@ serve_request(struct gmnisrv_client *client)
"Not found", NULL);
return;
}
- }
} else if (S_ISLNK(st.st_mode)) {
++nlinks;
if (nlinks > 3) {