]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
dig and mdig failed to properly preparse dash value pairs when value was a seperate...
authorMark Andrews <marka@isc.org>
Tue, 6 Nov 2018 00:59:04 +0000 (11:59 +1100)
committerMark Andrews <marka@isc.org>
Tue, 13 Nov 2018 21:39:05 +0000 (08:39 +1100)
CHANGES
bin/dig/dig.c
bin/tools/mdig.c

diff --git a/CHANGES b/CHANGES
index 2c8a9b59f4a673d49ad1bbd636aeac84325d1d11..0e8e2c933215232bed2131003ec8c0a5cdd472ad 100644 (file)
--- 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
index 47d18ae331bfba60081ae3b8507e27d7be7e5cc7..649918a484dc645a90e1a0229770ff37b6984ac6 100644 (file)
@@ -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;
        }
 }
 
index 9365b52fa714f32a4bbbc9a375bc9d9772b88127..35942687fe30959f477e5c2e1c450c60d94a5de8 100644 (file)
@@ -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;
        }
 }