]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables: fix error message for unknown options
authorJan Engelhardt <jengelh@medozas.de>
Mon, 7 Feb 2011 02:45:26 +0000 (03:45 +0100)
committerJan Engelhardt <jengelh@medozas.de>
Mon, 7 Feb 2011 03:09:27 +0000 (04:09 +0100)
-From: iptables v1.4.10: option "-q" requires an argument
+To:   iptables v1.4.10: unknown option "-q"

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
ip6tables.c
iptables.c

index 5a550bfb400afdb5bde2806db5ee4b9e834deb64..5561a7d5140d5be7a0b01769ba5ce9fd3fe4ad64 100644 (file)
@@ -1290,15 +1290,12 @@ static void command_default(struct iptables_command_state *cs)
                return;
        }
 
-       if (cs->c == '?') {
-               if (optopt)
-                       xtables_error(PARAMETER_PROBLEM,
-                               "option \"%s\" requires an argument",
-                               cs->argv[optind-1]);
-               else
-                       xtables_error(PARAMETER_PROBLEM,
-                               "unknown option \"%s\"", cs->argv[optind-1]);
-       }
+       if (cs->c == ':')
+               xtables_error(PARAMETER_PROBLEM, "option \"%s\" "
+                             "requires an argument", cs->argv[optind-1]);
+       if (cs->c == '?')
+               xtables_error(PARAMETER_PROBLEM, "unknown option "
+                             "\"%s\"", cs->argv[optind-1]);
        xtables_error(PARAMETER_PROBLEM, "Unknown arg \"%s\"", optarg);
 }
 
@@ -1396,7 +1393,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
 
        opts = xt_params->orig_opts;
        while ((cs.c = getopt_long(argc, argv,
-          "-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:bvnt:m:xc:g:",
+          "-:A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:bvnt:m:xc:g:",
                                           opts, NULL)) != -1) {
                switch (cs.c) {
                        /*
index 6f5616ba9cee0197713cd5e81e4e7bdfddadccc2..33fd88226aa8b91bd2919a48a74b8438febd0f81 100644 (file)
@@ -1316,15 +1316,12 @@ static void command_default(struct iptables_command_state *cs)
                return;
        }
 
-       if (cs->c == '?') {
-               if (optopt)
-                       xtables_error(PARAMETER_PROBLEM,
-                               "option \"%s\" requires an argument",
-                               cs->argv[optind-1]);
-               else
-                       xtables_error(PARAMETER_PROBLEM,
-                               "unknown option \"%s\"", cs->argv[optind-1]);
-       }
+       if (cs->c == ':')
+               xtables_error(PARAMETER_PROBLEM, "option \"%s\" "
+                             "requires an argument", cs->argv[optind-1]);
+       if (cs->c == '?')
+               xtables_error(PARAMETER_PROBLEM, "unknown option "
+                             "\"%s\"", cs->argv[optind-1]);
        xtables_error(PARAMETER_PROBLEM, "Unknown arg \"%s\"", optarg);
 }
 
@@ -1426,7 +1423,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle
 
        opts = xt_params->orig_opts;
        while ((cs.c = getopt_long(argc, argv,
-          "-A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:fbvnt:m:xc:g:",
+          "-:A:D:R:I:L::S::M:F::Z::N:X::E:P:Vh::o:p:s:d:j:i:fbvnt:m:xc:g:",
                                           opts, NULL)) != -1) {
                switch (cs.c) {
                        /*