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. 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(); } } }