From 56980be48ce636eec9fee2075a04b7a94e853599 Mon Sep 17 00:00:00 2001 From: cpq Date: Wed, 17 Feb 2021 16:07:18 +0000 Subject: [PATCH] Do not reveal full root dir path --- mongoose.c | 3 ++- src/http.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index bb43e9df..be2b3f05 100644 --- a/mongoose.c +++ b/mongoose.c @@ -1085,7 +1085,8 @@ void mg_http_serve_dir(struct mg_connection *c, struct mg_http_message *hm, if (realpath(t1, t2) == NULL) { LOG(LL_ERROR, ("realpath(%s): %d", t1, errno)); - mg_http_reply(c, 400, "", "Error serving [%s]\n", t1); + mg_http_reply(c, 404, "", "Not found [%.*s]\n", (int) hm->uri.len, + hm->uri.ptr); return; } diff --git a/src/http.c b/src/http.c index e61a1ece..de89cf41 100644 --- a/src/http.c +++ b/src/http.c @@ -665,7 +665,8 @@ void mg_http_serve_dir(struct mg_connection *c, struct mg_http_message *hm, if (realpath(t1, t2) == NULL) { LOG(LL_ERROR, ("realpath(%s): %d", t1, errno)); - mg_http_reply(c, 400, "", "Error serving [%s]\n", t1); + mg_http_reply(c, 404, "", "Not found [%.*s]\n", (int) hm->uri.len, + hm->uri.ptr); return; }