main: fix leaking -p/-s argument values
[project/uhttpd.git] / main.c
diff --git a/main.c b/main.c
index 13d02a4f101512c01be6a3141f8cb186f18487ff..de5f2c3a6bcb298385e8840606eae19f737c4c43 100644 (file)
--- a/main.c
+++ b/main.c
@@ -144,6 +144,7 @@ static int usage(const char *name)
 #endif
                "       -h directory    Specify the document root, default is '.'\n"
                "       -E string       Use given virtual URL as 404 error handler\n"
+               "       -b string       Use given charset for directory listings, default to UTF-8\n"
                "       -I string       Use given filename as index for directories, multiple allowed\n"
                "       -S              Do not follow symbolic links outside of the docroot\n"
                "       -D              Do not allow directory listings, send 403 instead\n"
@@ -151,8 +152,12 @@ static int usage(const char *name)
                "       -n count        Maximum allowed number of concurrent script requests\n"
                "       -N count        Maximum allowed number of concurrent connections\n"
 #ifdef HAVE_LUA
-               "       -l string       URL prefix for Lua handler, default is '/lua'\n"
-               "       -L file         Lua handler script, omit to disable Lua\n"
+               "       -l string       URL prefix for Lua handler\n"
+               "       -L file         Path to Lua handler script, -l and -L may be repeated in pairs\n"
+#endif
+#ifdef HAVE_UCODE
+               "       -o string       URL prefix for ucode handler\n"
+               "       -O file         Path to ucode handler script, -o and -O may be repeated in pairs\n"
 #endif
 #ifdef HAVE_UBUS
                "       -u string       URL prefix for UBUS via JSON-RPC handler\n"
@@ -288,7 +293,7 @@ int main(int argc, char **argv)
        init_defaults_pre();
        signal(SIGPIPE, SIG_IGN);
 
-       while ((ch = getopt(argc, argv, "A:aC:c:Dd:E:e:fh:H:I:i:K:k:L:l:m:N:n:O:o:P:p:qRr:Ss:T:t:U:u:Xx:y:")) != -1) {
+       while ((ch = getopt(argc, argv, "A:ab:C:c:Dd:E:e:fh:H:I:i:K:k:L:l:m:N:n:O:o:P:p:qRr:Ss:T:t:U:u:Xx:y:")) != -1) {
                switch(ch) {
 #ifdef HAVE_TLS
                case 'C':
@@ -323,6 +328,7 @@ int main(int argc, char **argv)
                case 'p':
                        optarg = strdup(optarg);
                        bound += add_listener_arg(optarg, (ch == 's'));
+                       free(optarg);
                        break;
 
                case 'h':
@@ -360,6 +366,10 @@ int main(int argc, char **argv)
                        uh_index_add(optarg);
                        break;
 
+               case 'b':
+                       conf.dirlist_charset = optarg;
+                       break;
+
                case 'S':
                        conf.no_symlinks = 1;
                        break;