]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #109: check number of arguments for stdin-pipes in
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 11 Nov 2019 11:02:51 +0000 (12:02 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 11 Nov 2019 11:02:51 +0000 (12:02 +0100)
  unbound-control and fail if too many arguments.

doc/Changelog
smallapp/unbound-control.c

index 3a00c686e01a354df1cb4ade4e0398f544cae832..a1981c931e7c02c67260a24b8a7ebd1b394b0371 100644 (file)
@@ -1,3 +1,7 @@
+11 November 2019: Wouter
+       - Fix #109: check number of arguments for stdin-pipes in
+         unbound-control and fail if too many arguments.
+
 24 October 2019: Wouter
        - Fix #99: Memory leak in ub_ctx (event_base will never be freed).
 
index 01e2385faab71331c5c066ef2f2f5a22a2bb24e3..ebaa70559328ec9fc5a233a8ab76b9ec49cf6470 100644 (file)
@@ -690,6 +690,27 @@ remote_write(SSL* ssl, int fd, const char* buf, size_t len)
        }
 }
 
+/** check args, to see if too many args. Because when a file is sent it
+ * would wait for the terminal, and we can check for too many arguments,
+ * eg. user put arguments on the commandline. */
+static void
+check_args_for_listcmd(int argc, char* argv[])
+{
+       if(argc >= 1 && (strcmp(argv[0], "local_zones") == 0 ||
+               strcmp(argv[0], "local_zones_remove") == 0 ||
+               strcmp(argv[0], "local_datas") == 0 ||
+               strcmp(argv[0], "local_datas_remove") == 0) &&
+               argc >= 2) {
+               fatal_exit("too many arguments for command '%s', "
+                       "content is piped in from stdin", argv[0]);
+       }
+       if(argc >= 1 && strcmp(argv[0], "view_local_datas") == 0 &&
+               argc >= 3) {
+               fatal_exit("too many arguments for command '%s', "
+                       "content is piped in from stdin", argv[0]);
+       }
+}
+
 /** send stdin to server */
 static void
 send_file(SSL* ssl, int fd, FILE* in, char* buf, size_t sz)
@@ -853,6 +874,7 @@ int main(int argc, char* argv[])
                print_stats_shm(cfgfile);
                return 0;
        }
+       check_args_for_listcmd(argc, argv);
 
 #ifdef USE_WINSOCK
        if((r = WSAStartup(MAKEWORD(2,2), &wsa_data)) != 0)