From bbe83862a5e1baf15f7c923352d4afdf59bc70e2 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sat, 24 Oct 2009 00:45:33 +0200 Subject: iptables/extensions: make bundled options work again When using a bundled option like "-ptcp", 'argv[optind-1]' would logically point to "-ptcp", but this is obviously not right. 'optarg' is needed instead, which if properly offset to "tcp". Not all places change optind-based access to optarg; where look-ahead is needed, such as for tcp's --tcp-flags option for example, optind is ok. References: http://bugzilla.netfilter.org/show_bug.cgi?id=611 Signed-off-by: Jan Engelhardt --- iptables.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'iptables.c') diff --git a/iptables.c b/iptables.c index d778c12c..a69aab30 100644 --- a/iptables.c +++ b/iptables.c @@ -1520,10 +1520,10 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle invert); /* Canonicalize into lower case */ - for (protocol = argv[optind-1]; *protocol; protocol++) + for (protocol = optarg; *protocol; protocol++) *protocol = tolower(*protocol); - protocol = argv[optind-1]; + protocol = optarg; fw.ip.proto = xtables_parse_protocol(protocol); if (fw.ip.proto == 0 @@ -1536,14 +1536,14 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle xtables_check_inverse(optarg, &invert, &optind, argc, argv); set_option(&options, OPT_SOURCE, &fw.ip.invflags, invert); - shostnetworkmask = argv[optind-1]; + shostnetworkmask = optarg; break; case 'd': xtables_check_inverse(optarg, &invert, &optind, argc, argv); set_option(&options, OPT_DESTINATION, &fw.ip.invflags, invert); - dhostnetworkmask = argv[optind-1]; + dhostnetworkmask = optarg; break; #ifdef IPT_F_GOTO @@ -1589,7 +1589,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle xtables_check_inverse(optarg, &invert, &optind, argc, argv); set_option(&options, OPT_VIANAMEIN, &fw.ip.invflags, invert); - xtables_parse_interface(argv[optind-1], + xtables_parse_interface(optarg, fw.ip.iniface, fw.ip.iniface_mask); break; @@ -1598,7 +1598,7 @@ int do_command(int argc, char *argv[], char **table, struct iptc_handle **handle xtables_check_inverse(optarg, &invert, &optind, argc, argv); set_option(&options, OPT_VIANAMEOUT, &fw.ip.invflags, invert); - xtables_parse_interface(argv[optind-1], + xtables_parse_interface(optarg, fw.ip.outiface, fw.ip.outiface_mask); break; -- cgit v1.2.3