]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xshared: Explicitly pass target to command_jump()
authorPhil Sutter <phil@nwl.cc>
Tue, 5 Feb 2019 16:01:42 +0000 (17:01 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 7 Feb 2019 14:51:58 +0000 (15:51 +0100)
The use of global 'optarg' variable inside that function is a mess, but
most importantly it limits its applicability to input parsers. Fix this
by having it take the option argument as a parameter.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/ip6tables.c
iptables/iptables.c
iptables/xshared.c
iptables/xshared.h
iptables/xtables-arp.c
iptables/xtables-eb-translate.c
iptables/xtables-eb.c
iptables/xtables.c

index fe089de4c85d76ab166b4a449bf30e61045663e4..050afa9a36458c3721c4595244d9032f3159d270 100644 (file)
@@ -1441,7 +1441,7 @@ int do_command6(int argc, char *argv[], char **table,
                case 'j':
                        set_option(&cs.options, OPT_JUMP, &cs.fw6.ipv6.invflags,
                                        cs.invert);
-                       command_jump(&cs);
+                       command_jump(&cs, optarg);
                        break;
 
 
index f8041f56ce70daf237ad3d610ff95c6a12d184d6..38c4bfe8ecf5c7d9d8e24afa67db876688b870d9 100644 (file)
@@ -1421,7 +1421,7 @@ int do_command4(int argc, char *argv[], char **table,
                case 'j':
                        set_option(&cs.options, OPT_JUMP, &cs.fw.ip.invflags,
                                   cs.invert);
-                       command_jump(&cs);
+                       command_jump(&cs, optarg);
                        break;
 
 
index b16f5fa68e56948074ca1a42dd2d3306bd38fa31..fb186fb1ac657b7ff5816bd4eda4be6e9df3e5ff 100644 (file)
@@ -653,12 +653,12 @@ const char *xt_parse_target(const char *targetname)
        return targetname;
 }
 
-void command_jump(struct iptables_command_state *cs)
+void command_jump(struct iptables_command_state *cs, const char *jumpto)
 {
        struct option *opts = xt_params->opts;
        size_t size;
 
-       cs->jumpto = xt_parse_target(optarg);
+       cs->jumpto = xt_parse_target(jumpto);
        /* TRY_LOAD (may be chain name) */
        cs->target = xtables_find_target(cs->jumpto, XTF_TRY_LOAD);
 
index db499f29236ed475a552a2871a1656e4846fb894..fd1f96bad1b989a33324fc5ccaf95d312a44500c 100644 (file)
@@ -176,6 +176,6 @@ void print_ifaces(const char *iniface, const char *outiface, uint8_t invflags,
 
 void command_match(struct iptables_command_state *cs);
 const char *xt_parse_target(const char *targetname);
-void command_jump(struct iptables_command_state *cs);
+void command_jump(struct iptables_command_state *cs, const char *jumpto);
 
 #endif /* IPTABLES_XSHARED_H */
index 4b663775c5bee110d4d906044ec639b5f8b41d39..d3cb9df823febbc2561831260d9779c0bcafba96 100644 (file)
@@ -1161,7 +1161,7 @@ int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table,
                case 'j':
                        set_option(&options, OPT_JUMP, &cs.arp.arp.invflags,
                                   invert);
-                       command_jump(&cs);
+                       command_jump(&cs, optarg);
                        break;
 
                case 'i':
index 0fe14d2d0db320791fcd080b1fa5666abdf2b654..96b2730fa97edea172714b750de22c9e96b06a38 100644 (file)
@@ -390,7 +390,7 @@ print_zero:
                                break;
                        } else if (c == 'j') {
                                ebt_check_option2(&flags, OPT_JUMP);
-                               command_jump(&cs);
+                               command_jump(&cs, optarg);
                                break;
                        } else if (c == 's') {
                                ebt_check_option2(&flags, OPT_SOURCE);
index 75d43963d5ef868e2ef6b00e2ba9013447cf9f94..4d2e6f683bebb60e8d4a54eb602195dd1332f9ad 100644 (file)
@@ -1011,7 +1011,7 @@ print_zero:
                        } else if (c == 'j') {
                                ebt_check_option2(&flags, OPT_JUMP);
                                if (strcmp(optarg, "CONTINUE") != 0) {
-                                       command_jump(&cs);
+                                       command_jump(&cs, optarg);
                                }
                                break;
                        } else if (c == 's') {
index eaa9fedeb03bbb07880f836c149186958f4035c0..1d777554076d758ec65499bd36f865acb85b7d94 100644 (file)
@@ -820,7 +820,7 @@ void do_parse(struct nft_handle *h, int argc, char *argv[],
                case 'j':
                        set_option(&cs->options, OPT_JUMP, &cs->fw.ip.invflags,
                                   cs->invert);
-                       command_jump(cs);
+                       command_jump(cs, optarg);
                        break;