From: Jo-Philipp Wich Date: Sat, 26 Jan 2013 13:46:59 +0000 (+0100) Subject: set the docroot to the current working directory if none is specified, fixes random... X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuhttpd.git;a=commitdiff_plain;h=ac7670faba12e23b8ec7e866dcfe1d98d3921b40 set the docroot to the current working directory if none is specified, fixes random null pointer dereferencing --- diff --git a/main.c b/main.c index 8cf4027..f88506c 100644 --- a/main.c +++ b/main.c @@ -399,6 +399,14 @@ int main(int argc, char **argv) return 1; } + if (!conf.docroot) { + if (!realpath(".", uh_buf)) { + fprintf(stderr, "Error: Unable to determine work dir\n"); + return 1; + } + conf.docroot = strdup(uh_buf); + } + #ifdef HAVE_TLS if (n_tls) { if (!tls_crt || !tls_key) {