From f73816ff0fda101ebe61213ed4352c1f245b3329 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 23 Jan 2019 17:47:59 +1100 Subject: [PATCH] error out if there are extra command line options --- CHANGES | 3 +++ bin/dig/nslookup.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGES b/CHANGES index a05aa09c08..2a668d1fef 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5157. [bug] Nslookup now errors out if there are extra command + line arguments. [GL #207] + --- 9.13.6 released --- 5156. [doc] Extended and refined the section of the ARM describing diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 163f68d057..e61de912b2 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -879,6 +879,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; @@ -900,6 +917,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; }