]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Report unknown dash option during the pre-parse phase
authorMark Andrews <marka@isc.org>
Thu, 21 Jan 2021 22:58:06 +0000 (09:58 +1100)
committerOndřej Surý <ondrej@isc.org>
Tue, 26 Jan 2021 13:18:54 +0000 (14:18 +0100)
(cherry picked from commit 3361c0d6f862ba60957a3eb6bc46658572f126ae)

bin/dig/dig.c

index a0b7ab00545c67a9f4e78701488ac525d1acbffa..af1a5e33af15e389c35f418c496b38413815d444 100644 (file)
@@ -2197,16 +2197,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();
                }
        }
 }