Skip to contentSkip to conversation

ip{,6}tables-restore: Fix wait-interval parsing

PATCH Applied Phil Sutter 2 participants 4 messages Sep 20, 2017 – Oct 4, 2017 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

cover ip{,6}tables-restore: Fix wait-interval parsing

This series fixes two problems with parsing of --wait-interval (-W) option.

Phil Sutter (2):
ip{,6}tables-restore: Don't ignore missing wait-interval value ip{,6}tables-restore: Don't accept wait-interval without wait

 iptables/ip6tables-restore.c | 5 +++++
 iptables/iptables-restore.c  | 5 +++++
 iptables/xshared.c           | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.13.1
author reviewer
#1 lore raw

PATCH 1/2 ip{,6}tables-restore: Don't ignore missing wait-interval value

Passing -W without a value doesn't make sense so bail out if none was given.

---
 iptables/xshared.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
iptables/xshared.c +1 -1
index 825479c338214..06db72d427e21 100644
@@ -343,7 +343,7 @@ void parse_wait_interval(int argc, char *argv[], struct timeval *wait_interval)
 	else if (xs_has_arg(argc, argv))
 		arg = argv[optind++];
 	else
-		return;
+		xtables_error(PARAMETER_PROBLEM, "wait interval value required");
 
 	ret = sscanf(arg, "%u", &usec);
 	if (ret == 1) {
Signature · 1 line
2.13.1
author reviewer
#2 lore raw

PATCH 2/2 ip{,6}tables-restore: Don't accept wait-interval without wait

In reply to Phil Sutter

If -W <val> was given, error out if -w wasn't since that doesn't make sense.

---
 iptables/ip6tables-restore.c | 5 +++++
 iptables/iptables-restore.c  | 5 +++++
 2 files changed, 10 insertions(+)
iptables/ip6tables-restore.c +5 -0
index eaa2bcbc3856e..47310f20b9363 100644
@@ -273,6 +273,11 @@ int ip6tables_restore_main(int argc, char *argv[])
 	}
 	else in = stdin;
 
+	if (!wait_interval.tv_sec && !wait) {
+		fprintf(stderr, "Option --wait-interval requires option --wait\n");
+		exit(1);
+	}
+
 	/* Grab standard input. */
 	while (fgets(buffer, sizeof(buffer), in)) {
 		int ret = 0;
iptables/iptables-restore.c +5 -0
index 9dbfc572a7cec..074552af5dc74 100644
@@ -271,6 +271,11 @@ iptables_restore_main(int argc, char *argv[])
 	}
 	else in = stdin;
 
+	if (!wait_interval.tv_sec && !wait) {
+		fprintf(stderr, "Option --wait-interval requires option --wait\n");
+		exit(1);
+	}
+
 	/* Grab standard input. */
 	while (fgets(buffer, sizeof(buffer), in)) {
 		int ret = 0;
Signature · 1 line
2.13.1