From cb042d6263a0f6800b298373b24a64b407aaf2f0 Mon Sep 17 00:00:00 2001 From: Eyal Sawady Date: Sun, 15 Nov 2020 11:32:59 -0500 Subject: [PATCH] CGI: Don't hang on directory with no index --- src/serve.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/serve.c b/src/serve.c index 677b6a4..71f97c5 100644 --- a/src/serve.c +++ b/src/serve.c @@ -459,6 +459,14 @@ serve_request(struct gmnisrv_client *client) strncat(real_path, route->index ? route->index : "index.gmi", sizeof(real_path) - 1); + if (stat(real_path, &st) != 0) { + server_error("CGI path %s has no index", + client_path); + client_submit_response(client, + GEMINI_STATUS_NOT_FOUND, + "Not found", NULL); + return; + } } } else if (S_ISLNK(st.st_mode)) { ++nlinks;