From 3361c0d6f862ba60957a3eb6bc46658572f126ae Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 22 Jan 2021 09:58:06 +1100 Subject: [PATCH 1/2] Report unknown dash option during the pre-parse phase --- bin/dig/dig.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 711dedf430..76c491f073 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -2341,16 +2341,20 @@ preparse_args(int argc, char **argv) { continue; } /* Look for dash value option. */ - if (strpbrk(option, dash_opts) != &option[0] || - strlen(option) > 1U) { - /* Error or value in option. */ + if (strpbrk(option, dash_opts) != &option[0]) { + goto invalid_option; + } + if (strlen(option) > 1U) { + /* value in option. */ continue; } /* Dash value is next argument so we need to skip it. */ rc--, rv++; /* Handle missing argument */ if (rc == 0) { - break; + invalid_option: + fprintf(stderr, "Invalid option: -%s\n", option); + usage(); } } } From 0b6da18f31f4693fe9ecb577646601bbb7352413 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 22 Jan 2021 10:04:37 +1100 Subject: [PATCH 2/2] Add CHANGES note for [GL #2403] --- CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 987862f2d8..e5c524acb6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +5567. [bug] Dig now reports unknown dash options while pre-parsing + the options. This prevents '-multi' instead of + '+multi' reporting memory usage before ending option + parsing on 'Invalid option: -lti'. [GL #2403] + 5566. [func] Add "stale-answer-client-timeout" option, which is the amount of time a recursive resolver waits before attempting to answer the query using stale data from cache.