From 93b97402337f486e568c5508915b75a7ad54d39b Mon Sep 17 00:00:00 2001 From: chme Date: Sun, 4 Jul 2021 11:41:39 +0200 Subject: [PATCH] [httpd] Dereference web root directory to allow symlinks --- src/httpd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/httpd.c b/src/httpd.c index 6c1d5968..f0c76f76 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -121,7 +121,7 @@ static const struct content_type_map ext2ctype[] = static const char *http_reply_401 = "401 UnauthorizedAuthorization required"; -static const char *webroot_directory; +static char webroot_directory[PATH_MAX]; struct event_base *evbase_httpd; #ifdef HAVE_EVENTFD @@ -1649,7 +1649,12 @@ httpd_init(const char *webroot) return -1; } - webroot_directory = webroot; + if (!realpath(webroot, webroot_directory)) + { + DPRINTF(E_LOG, L_HTTPD, "Web root directory '%s' could not be dereferenced: %s\n", webroot, strerror(errno)); + + return -1; + } evbase_httpd = event_base_new(); if (!evbase_httpd)