[PATCH 11/11] iptables: fix error message for unknown options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-From: iptables v1.4.10: option "-q" requires an argument
+To:   iptables v1.4.10: unknown option "-q"

Signed-off-by: Jan Engelhardt <jengelh@xxxxxxxxxx>
---
 ip6tables.c |   17 +++++++----------
 iptables.c  |   17 +++++++----------
 2 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/ip6tables.c b/ip6tables.c
index 5a550bf..5561a7d 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -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) {
 			/*
diff --git a/iptables.c b/iptables.c
index 6f5616b..33fd882 100644
--- a/iptables.c
+++ b/iptables.c
@@ -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) {
 			/*
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux