Blame SOURCES/0050-xshared-Explicitly-pass-target-to-command_jump.patch

1dc35b
From 715e2fa36e08f0ee800347d8abea039e5347b1dc Mon Sep 17 00:00:00 2001
8cce6c
From: Phil Sutter <phil@nwl.cc>
8cce6c
Date: Tue, 5 Feb 2019 17:01:42 +0100
8cce6c
Subject: [PATCH] xshared: Explicitly pass target to command_jump()
8cce6c
8cce6c
The use of global 'optarg' variable inside that function is a mess, but
8cce6c
most importantly it limits its applicability to input parsers. Fix this
8cce6c
by having it take the option argument as a parameter.
8cce6c
8cce6c
Signed-off-by: Phil Sutter <phil@nwl.cc>
8cce6c
Signed-off-by: Florian Westphal <fw@strlen.de>
8cce6c
(cherry picked from commit 932d5c3fb94acc499c8a6264e354ab1e33316b72)
8cce6c
Signed-off-by: Phil Sutter <psutter@redhat.com>
8cce6c
---
8cce6c
 iptables/ip6tables.c            | 2 +-
8cce6c
 iptables/iptables.c             | 2 +-
8cce6c
 iptables/xshared.c              | 4 ++--
8cce6c
 iptables/xshared.h              | 2 +-
8cce6c
 iptables/xtables-arp.c          | 2 +-
8cce6c
 iptables/xtables-eb-translate.c | 2 +-
8cce6c
 iptables/xtables-eb.c           | 2 +-
8cce6c
 iptables/xtables.c              | 2 +-
8cce6c
 8 files changed, 9 insertions(+), 9 deletions(-)
8cce6c
8cce6c
diff --git a/iptables/ip6tables.c b/iptables/ip6tables.c
8cce6c
index fe089de4c85d7..050afa9a36458 100644
8cce6c
--- a/iptables/ip6tables.c
8cce6c
+++ b/iptables/ip6tables.c
8cce6c
@@ -1441,7 +1441,7 @@ int do_command6(int argc, char *argv[], char **table,
8cce6c
 		case 'j':
8cce6c
 			set_option(&cs.options, OPT_JUMP, &cs.fw6.ipv6.invflags,
8cce6c
 					cs.invert);
8cce6c
-			command_jump(&cs);
8cce6c
+			command_jump(&cs, optarg);
8cce6c
 			break;
8cce6c
 
8cce6c
 
8cce6c
diff --git a/iptables/iptables.c b/iptables/iptables.c
8cce6c
index f8041f56ce70d..38c4bfe8ecf5c 100644
8cce6c
--- a/iptables/iptables.c
8cce6c
+++ b/iptables/iptables.c
8cce6c
@@ -1421,7 +1421,7 @@ int do_command4(int argc, char *argv[], char **table,
8cce6c
 		case 'j':
8cce6c
 			set_option(&cs.options, OPT_JUMP, &cs.fw.ip.invflags,
8cce6c
 				   cs.invert);
8cce6c
-			command_jump(&cs);
8cce6c
+			command_jump(&cs, optarg);
8cce6c
 			break;
8cce6c
 
8cce6c
 
8cce6c
diff --git a/iptables/xshared.c b/iptables/xshared.c
8cce6c
index b16f5fa68e569..fb186fb1ac657 100644
8cce6c
--- a/iptables/xshared.c
8cce6c
+++ b/iptables/xshared.c
8cce6c
@@ -653,12 +653,12 @@ const char *xt_parse_target(const char *targetname)
8cce6c
 	return targetname;
8cce6c
 }
8cce6c
 
8cce6c
-void command_jump(struct iptables_command_state *cs)
8cce6c
+void command_jump(struct iptables_command_state *cs, const char *jumpto)
8cce6c
 {
8cce6c
 	struct option *opts = xt_params->opts;
8cce6c
 	size_t size;
8cce6c
 
8cce6c
-	cs->jumpto = xt_parse_target(optarg);
8cce6c
+	cs->jumpto = xt_parse_target(jumpto);
8cce6c
 	/* TRY_LOAD (may be chain name) */
8cce6c
 	cs->target = xtables_find_target(cs->jumpto, XTF_TRY_LOAD);
8cce6c
 
8cce6c
diff --git a/iptables/xshared.h b/iptables/xshared.h
8cce6c
index db499f29236ed..fd1f96bad1b98 100644
8cce6c
--- a/iptables/xshared.h
8cce6c
+++ b/iptables/xshared.h
8cce6c
@@ -176,6 +176,6 @@ void print_ifaces(const char *iniface, const char *outiface, uint8_t invflags,
8cce6c
 
8cce6c
 void command_match(struct iptables_command_state *cs);
8cce6c
 const char *xt_parse_target(const char *targetname);
8cce6c
-void command_jump(struct iptables_command_state *cs);
8cce6c
+void command_jump(struct iptables_command_state *cs, const char *jumpto);
8cce6c
 
8cce6c
 #endif /* IPTABLES_XSHARED_H */
8cce6c
diff --git a/iptables/xtables-arp.c b/iptables/xtables-arp.c
8cce6c
index 85bcc841b21f5..4a873b15c6833 100644
8cce6c
--- a/iptables/xtables-arp.c
8cce6c
+++ b/iptables/xtables-arp.c
8cce6c
@@ -1161,7 +1161,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table,
8cce6c
 		case 'j':
8cce6c
 			set_option(&options, OPT_JUMP, &cs.arp.arp.invflags,
8cce6c
 				   invert);
8cce6c
-			command_jump(&cs);
8cce6c
+			command_jump(&cs, optarg);
8cce6c
 			break;
8cce6c
 
8cce6c
 		case 'i':
8cce6c
diff --git a/iptables/xtables-eb-translate.c b/iptables/xtables-eb-translate.c
8cce6c
index 0fe14d2d0db32..96b2730fa97ed 100644
8cce6c
--- a/iptables/xtables-eb-translate.c
8cce6c
+++ b/iptables/xtables-eb-translate.c
8cce6c
@@ -390,7 +390,7 @@ print_zero:
8cce6c
 				break;
8cce6c
 			} else if (c == 'j') {
8cce6c
 				ebt_check_option2(&flags, OPT_JUMP);
8cce6c
-				command_jump(&cs);
8cce6c
+				command_jump(&cs, optarg);
8cce6c
 				break;
8cce6c
 			} else if (c == 's') {
8cce6c
 				ebt_check_option2(&flags, OPT_SOURCE);
8cce6c
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
8cce6c
index 55cb0fe204748..21344843a365a 100644
8cce6c
--- a/iptables/xtables-eb.c
8cce6c
+++ b/iptables/xtables-eb.c
8cce6c
@@ -1022,7 +1022,7 @@ print_zero:
8cce6c
 			} else if (c == 'j') {
8cce6c
 				ebt_check_option2(&flags, OPT_JUMP);
8cce6c
 				if (strcmp(optarg, "CONTINUE") != 0) {
8cce6c
-					command_jump(&cs);
8cce6c
+					command_jump(&cs, optarg);
8cce6c
 				}
8cce6c
 				break;
8cce6c
 			} else if (c == 's') {
8cce6c
diff --git a/iptables/xtables.c b/iptables/xtables.c
8cce6c
index eaa9fedeb03bb..1d777554076d7 100644
8cce6c
--- a/iptables/xtables.c
8cce6c
+++ b/iptables/xtables.c
8cce6c
@@ -820,7 +820,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
8cce6c
 		case 'j':
8cce6c
 			set_option(&cs->options, OPT_JUMP, &cs->fw.ip.invflags,
8cce6c
 				   cs->invert);
8cce6c
-			command_jump(cs);
8cce6c
+			command_jump(cs, optarg);
8cce6c
 			break;
8cce6c
 
8cce6c
 
8cce6c
-- 
1dc35b
2.21.0
8cce6c