cgi: allow conf.cgi_docroot_path to be NULL
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 8 Oct 2015 17:45:00 +0000 (19:45 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 25 Oct 2016 14:32:50 +0000 (16:32 +0200)
The check_cgi_path() function would segfault if we ever support running
uhttpd without any CGI prefix.

Add a check to prevent running uh_patch_match() when the prefix is unset.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
cgi.c

diff --git a/cgi.c b/cgi.c
index dc302a9acf32c28d3869ca63176ff418dcd7880c..0ffb1308c6141b5339a9fa41ac8f64c55f15266b 100644 (file)
--- a/cgi.c
+++ b/cgi.c
@@ -104,7 +104,11 @@ static bool check_cgi_path(struct path_info *pi, const char *url)
        }
 
        pi->ip = NULL;
-       return uh_path_match(conf.cgi_docroot_path, pi->phys);
+
+       if (conf.cgi_docroot_path)
+               return uh_path_match(conf.cgi_docroot_path, pi->phys);
+
+       return false;
 }
 
 struct dispatch_handler cgi_dispatch = {