From: Mark Andrews Date: Tue, 6 Nov 2018 00:59:04 +0000 (+1100) Subject: dig and mdig failed to properly preparse dash value pairs when value was a seperate... X-Git-Tag: v9.13.4~30^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75fa84b67b13bd47ce509f9379747b2cd4e457c9;p=thirdparty%2Fbind9.git dig and mdig failed to properly preparse dash value pairs when value was a seperate argument and started with a dash. --- diff --git a/CHANGES b/CHANGES index 2c8a9b59f4a..0e8e2c93321 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +5090. [bug] dig and mdig failed to properly preparse dash value + pairs when value was a seperate argument and started + with a dash. [GL #584] + 5089. [bug] Restore localhost fallback in dig and host which is used when no nameserver addresses present in /etc/resolv.conf are usable due to the requested diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 47d18ae331b..649918a484d 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -1859,6 +1859,20 @@ preparse_args(int argc, char **argv) { } option = &option[1]; } + if (strlen(option) == 0U) { + continue; + } + /* Look for dash value option. */ + if (strpbrk(option, dash_opts) != &option[0] || + strlen(option) > 1U) { + /* Error or value in option. */ + continue; + } + /* Dash value is next argument so we need to skip it. */ + rc--, rv++; + /* Handle missing argument */ + if (rc == 0) + break; } } diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 9365b52fa71..35942687fe3 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -1535,7 +1535,7 @@ plus_option(char *option, struct query *query, bool global) * #true returned if value was used */ static const char *single_dash_opts = "46himv"; -/*static const char *dash_opts = "46bcfhiptvx";*/ +static const char *dash_opts = "46bcfhiptvx"; static bool dash_option(const char *option, char *next, struct query *query, bool global, bool *setname) @@ -1755,6 +1755,20 @@ preparse_args(int argc, char **argv) { } option = &option[1]; } + if (strlen(option) == 0U) { + continue; + } + /* Look for dash value option. */ + if (strpbrk(option, dash_opts) != &option[0] || + strlen(option) > 1U) { + /* Error or value in option. */ + continue; + } + /* Dash value is next argument so we need to skip it. */ + rc--, rv++; + /* Handle missing argument */ + if (rc == 0) + break; } }