]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
error out if there are extra command line options
authorMark Andrews <marka@isc.org>
Wed, 23 Jan 2019 06:47:59 +0000 (17:47 +1100)
committerMark Andrews <marka@isc.org>
Thu, 7 Feb 2019 12:46:13 +0000 (23:46 +1100)
(cherry picked from commit f73816ff0fda101ebe61213ed4352c1f245b3329)

CHANGES
bin/dig/nslookup.c

diff --git a/CHANGES b/CHANGES
index 21a647357d902a0132c5fdb70bed1ec55d1a548f..2ee4a3e57a13b6ae9c1f9b9fe4c39ecc3db9d484 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+5157.  [bug]           Nslookup now errors out if there are extra command
+                       line arguments. [GL #207]
+
 5154.  [bug]           dig: process_opt could be called twice on the same
                        message leading to a assertion failure. [GL #860]
 
index 59bd01b5c5dd4f6b87ce7cd1f7151001a23c33fa..9eccb08d6a22fb47c5decca956969300befb6f1d 100644 (file)
@@ -891,6 +891,23 @@ get_next_command(void) {
        isc_mem_free(mctx, buf);
 }
 
+ISC_PLATFORM_NORETURN_PRE static void
+usage(void) ISC_PLATFORM_NORETURN_POST;
+
+static void
+usage(void) {
+    fprintf(stderr, "Usage:\n");
+    fprintf(stderr,
+"   nslookup [-opt ...]             # interactive mode using default server\n");
+    fprintf(stderr,
+"   nslookup [-opt ...] - server    # interactive mode using 'server'\n");
+    fprintf(stderr,
+"   nslookup [-opt ...] host        # just look up 'host' using default server\n");
+    fprintf(stderr,
+"   nslookup [-opt ...] host server # just look up 'host' using 'server'\n");
+    exit(1);
+}
+
 static void
 parse_args(int argc, char **argv) {
        bool have_lookup = false;
@@ -912,6 +929,9 @@ parse_args(int argc, char **argv) {
                                in_use = true;
                                addlookup(argv[0]);
                        } else {
+                               if (argv[1] != NULL) {
+                                       usage();
+                               }
                                set_nameserver(argv[0]);
                                check_ra = false;
                        }