]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
iptables/extensions: make bundled options work again
authorJan Engelhardt <jengelh@medozas.de>
Fri, 23 Oct 2009 22:45:33 +0000 (00:45 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Tue, 3 Nov 2009 20:54:20 +0000 (21:54 +0100)
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 <jengelh@medozas.de>
39 files changed:
extensions/libip6t_ah.c
extensions/libip6t_dst.c
extensions/libip6t_frag.c
extensions/libip6t_hbh.c
extensions/libip6t_hl.c
extensions/libip6t_icmp6.c
extensions/libip6t_ipv6header.c
extensions/libip6t_mh.c
extensions/libip6t_rt.c
extensions/libipt_SET.c
extensions/libipt_addrtype.c
extensions/libipt_ah.c
extensions/libipt_icmp.c
extensions/libipt_realm.c
extensions/libipt_set.c
extensions/libxt_comment.c
extensions/libxt_connbytes.c
extensions/libxt_connlimit.c
extensions/libxt_conntrack.c
extensions/libxt_dccp.c
extensions/libxt_dscp.c
extensions/libxt_esp.c
extensions/libxt_hashlimit.c
extensions/libxt_length.c
extensions/libxt_limit.c
extensions/libxt_mac.c
extensions/libxt_multiport.c
extensions/libxt_physdev.c
extensions/libxt_pkttype.c
extensions/libxt_rateest.c
extensions/libxt_sctp.c
extensions/libxt_state.c
extensions/libxt_string.c
extensions/libxt_tcp.c
extensions/libxt_tcpmss.c
extensions/libxt_u32.c
extensions/libxt_udp.c
ip6tables.c
iptables.c

index 474dd8fe8fc1a9c8f377766d2a32d6b7d4098ee0..285704c0392706ac196396e40395dce1e4badd64 100644 (file)
@@ -87,7 +87,7 @@ static int ah_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--ahspi' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_ah_spis(argv[optind-1], ahinfo->spis);
+               parse_ah_spis(optarg, ahinfo->spis);
                if (invert)
                        ahinfo->invflags |= IP6T_AH_INV_SPI;
                *flags |= IP6T_AH_SPI;
@@ -97,7 +97,7 @@ static int ah_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--ahlen' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               ahinfo->hdrlen = parse_ah_spi(argv[optind-1], "length");
+               ahinfo->hdrlen = parse_ah_spi(optarg, "length");
                if (invert)
                        ahinfo->invflags |= IP6T_AH_INV_LEN;
                *flags |= IP6T_AH_LEN;
index dfa4daf3de498f22383971aa8b2634ff9f7a7a50..72df6ad0147f7fbfab231ba06b769050b54e24fb 100644 (file)
@@ -126,7 +126,7 @@ static int dst_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--dst-len' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               optinfo->hdrlen = parse_opts_num(argv[optind-1], "length");
+               optinfo->hdrlen = parse_opts_num(optarg, "length");
                if (invert)
                        optinfo->invflags |= IP6T_OPTS_INV_LEN;
                optinfo->flags |= IP6T_OPTS_LEN;
@@ -140,7 +140,7 @@ static int dst_parse(int c, char **argv, int invert, unsigned int *flags,
                 if (invert)
                        xtables_error(PARAMETER_PROBLEM,
                                " '!' not allowed with `--dst-opts'");
-               optinfo->optsnr = parse_options(argv[optind-1], optinfo->opts);
+               optinfo->optsnr = parse_options(optarg, optinfo->opts);
                optinfo->flags |= IP6T_OPTS_OPTS;
                *flags |= IP6T_OPTS_OPTS;
                break;
index 8cc432b5c1428aacfa2dd06e24498005f52f4754..5a280cc1e6fabf4a687afe17bf43f243a2f446cb 100644 (file)
@@ -95,7 +95,7 @@ static int frag_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--fragid' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_frag_ids(argv[optind-1], fraginfo->ids);
+               parse_frag_ids(optarg, fraginfo->ids);
                if (invert)
                        fraginfo->invflags |= IP6T_FRAG_INV_IDS;
                fraginfo->flags |= IP6T_FRAG_IDS;
@@ -106,7 +106,7 @@ static int frag_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--fraglen' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               fraginfo->hdrlen = parse_frag_id(argv[optind-1], "length");
+               fraginfo->hdrlen = parse_frag_id(optarg, "length");
                if (invert)
                        fraginfo->invflags |= IP6T_FRAG_INV_LEN;
                fraginfo->flags |= IP6T_FRAG_LEN;
index b7532b66ddc176dc3ef7370a5827fdcc42d7b5aa..520ec9ed584546a41b51460c6cc953660c2548a0 100644 (file)
@@ -121,7 +121,7 @@ static int hbh_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--hbh-len' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               optinfo->hdrlen = parse_opts_num(argv[optind-1], "length");
+               optinfo->hdrlen = parse_opts_num(optarg, "length");
                if (invert)
                        optinfo->invflags |= IP6T_OPTS_INV_LEN;
                optinfo->flags |= IP6T_OPTS_LEN;
@@ -135,7 +135,7 @@ static int hbh_parse(int c, char **argv, int invert, unsigned int *flags,
                 if (invert)
                        xtables_error(PARAMETER_PROBLEM,
                                " '!' not allowed with `--hbh-opts'");
-               optinfo->optsnr = parse_options(argv[optind-1], optinfo->opts);
+               optinfo->optsnr = parse_options(optarg, optinfo->opts);
                optinfo->flags |= IP6T_OPTS_OPTS;
                *flags |= IP6T_OPTS_OPTS;
                break;
index 1abada04bf82cbd468a8072c8906b3d793c6c5e0..09589b1917757851067dca407844cdec0457f2dc 100644 (file)
@@ -30,7 +30,7 @@ static int hl_parse(int c, char **argv, int invert, unsigned int *flags,
        u_int8_t value;
 
        xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-       value = atoi(argv[optind-1]);
+       value = atoi(optarg);
 
        if (*flags) 
                xtables_error(PARAMETER_PROBLEM,
index 3cee0f9ddb6615c0fdf535078e055ed7b50a9276..fb321b3beab7f6a94f7780f4de37b123fa294236 100644 (file)
@@ -159,7 +159,7 @@ static int icmp6_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "icmpv6 match: only use --icmpv6-type once!");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_icmpv6(argv[optind-1], &icmpv6info->type, 
+               parse_icmpv6(optarg, &icmpv6info->type, 
                             icmpv6info->code);
                if (invert)
                        icmpv6info->invflags |= IP6T_ICMP_INV;
index 4a4e1df65d7d622d5cfa7fd7382be97bc16bf502..af1f5ef6fe90e874f1fcfdfc5ad8036dda23ddda 100644 (file)
@@ -187,7 +187,7 @@ ipv6header_parse(int c, char **argv, int invert, unsigned int *flags,
 
                        xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
-                       if (! (info->matchflags = parse_header(argv[optind-1])) )
+                       if (! (info->matchflags = parse_header(optarg)) )
                                xtables_error(PARAMETER_PROBLEM, "ip6t_ipv6header: cannot parse header names");
 
                        if (invert) 
index b659c5d3194bd0f011d9d596578823dac952a729..95cd65d1ea0c0659c553a97b4445eae4467e8404 100644 (file)
@@ -134,7 +134,7 @@ static int mh_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--mh-type' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_mh_types(argv[optind-1], mhinfo->types);
+               parse_mh_types(optarg, mhinfo->types);
                if (invert)
                        mhinfo->invflags |= IP6T_MH_INV_TYPE;
                *flags |= MH_TYPES;
index 851a600aec1b3c626aa8d88759907565b975f3f1..a04023df9d65109c6d2cc905974cdc3f1f4eea76 100644 (file)
@@ -159,7 +159,7 @@ static int rt_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--rt-type' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               rtinfo->rt_type = parse_rt_num(argv[optind-1], "type");
+               rtinfo->rt_type = parse_rt_num(optarg, "type");
                if (invert)
                        rtinfo->invflags |= IP6T_RT_INV_TYP;
                rtinfo->flags |= IP6T_RT_TYP;
@@ -170,7 +170,7 @@ static int rt_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--rt-segsleft' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_rt_segsleft(argv[optind-1], rtinfo->segsleft);
+               parse_rt_segsleft(optarg, rtinfo->segsleft);
                if (invert)
                        rtinfo->invflags |= IP6T_RT_INV_SGS;
                rtinfo->flags |= IP6T_RT_SGS;
@@ -181,7 +181,7 @@ static int rt_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--rt-len' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               rtinfo->hdrlen = parse_rt_num(argv[optind-1], "length");
+               rtinfo->hdrlen = parse_rt_num(optarg, "length");
                if (invert)
                        rtinfo->invflags |= IP6T_RT_INV_LEN;
                rtinfo->flags |= IP6T_RT_LEN;
@@ -208,7 +208,7 @@ static int rt_parse(int c, char **argv, int invert, unsigned int *flags,
                if (invert)
                        xtables_error(PARAMETER_PROBLEM,
                                   " '!' not allowed with `--rt-0-addrs'");
-               rtinfo->addrnr = parse_addresses(argv[optind-1], rtinfo->addrs);
+               rtinfo->addrnr = parse_addresses(optarg, rtinfo->addrs);
                rtinfo->flags |= IP6T_RT_FST;
                *flags |= IP6T_RT_FST;
                break;
index 20daf3be2f637a9a4a4a221fde3df3a6c18969fb..18cf7d48a817a37e7c11c00f7fbff71268c4163a 100644 (file)
@@ -65,12 +65,12 @@ parse_target(char **argv, int invert, unsigned int *flags,
                xtables_error(PARAMETER_PROBLEM,
                           "--%s requires two args.", what);
 
-       if (strlen(argv[optind-1]) > IP_SET_MAXNAMELEN - 1)
+       if (strlen(optarg) > IP_SET_MAXNAMELEN - 1)
                xtables_error(PARAMETER_PROBLEM,
                           "setname `%s' too long, max %d characters.",
-                          argv[optind-1], IP_SET_MAXNAMELEN - 1);
+                          optarg, IP_SET_MAXNAMELEN - 1);
 
-       get_set_byname(argv[optind - 1], info);
+       get_set_byname(optarg, info);
        parse_bindings(argv[optind], info);
        optind++;
        
index c3052812d6ba54f5ca3caad5c4b8158fbce6bccd..ad63dcf71f0e59640cb1850086596ffa4afdcb3e 100644 (file)
@@ -107,7 +107,7 @@ addrtype_parse_v0(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "addrtype: can't specify src-type twice");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_types(argv[optind-1], &info->source);
+               parse_types(optarg, &info->source);
                if (invert)
                        info->invert_source = 1;
                *flags |= IPT_ADDRTYPE_OPT_SRCTYPE;
@@ -117,7 +117,7 @@ addrtype_parse_v0(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "addrtype: can't specify dst-type twice");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_types(argv[optind-1], &info->dest);
+               parse_types(optarg, &info->dest);
                if (invert)
                        info->invert_dest = 1;
                *flags |= IPT_ADDRTYPE_OPT_DSTTYPE;
@@ -142,7 +142,7 @@ addrtype_parse_v1(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "addrtype: can't specify src-type twice");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_types(argv[optind-1], &info->source);
+               parse_types(optarg, &info->source);
                if (invert)
                        info->flags |= IPT_ADDRTYPE_INVERT_SOURCE;
                *flags |= IPT_ADDRTYPE_OPT_SRCTYPE;
@@ -152,7 +152,7 @@ addrtype_parse_v1(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "addrtype: can't specify dst-type twice");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_types(argv[optind-1], &info->dest);
+               parse_types(optarg, &info->dest);
                if (invert)
                        info->flags |= IPT_ADDRTYPE_INVERT_DEST;
                *flags |= IPT_ADDRTYPE_OPT_DSTTYPE;
index a2239f6e3253425f9b9ba631a4c9a3ebb99f549c..170cd8b9b4af7b3e54c17a063f5eb9006351edb7 100644 (file)
@@ -83,7 +83,7 @@ static int ah_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--ahspi' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_ah_spis(argv[optind-1], ahinfo->spis);
+               parse_ah_spis(optarg, ahinfo->spis);
                if (invert)
                        ahinfo->invflags |= IPT_AH_INV_SPI;
                *flags |= AH_SPI;
index b109c8ec1eceffd3596489333af25dcadb87b4d9..37b2fdcde612cf85a77d69b173d44d01eb5c3936 100644 (file)
@@ -184,7 +184,7 @@ static int icmp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "icmp match: only use --icmp-type once!");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_icmp(argv[optind-1], &icmpinfo->type, 
+               parse_icmp(optarg, &icmpinfo->type, 
                           icmpinfo->code);
                if (invert)
                        icmpinfo->invflags |= IPT_ICMP_INV;
index 8eb20677ff8af5235e955f40bc50d4174d5d1570..cd4b324bbbaddadf9f738c42da0d16b0a380da9b 100644 (file)
@@ -156,8 +156,8 @@ static int realm_parse(int c, char **argv, int invert, unsigned int *flags,
        switch (c) {
                char *end;
        case '1':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
-               end = optarg = argv[optind-1];
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
+               end = optarg = optarg;
                realminfo->id = strtoul(optarg, &end, 0);
                if (end != optarg && (*end == '/' || *end == '\0')) {
                        if (*end == '/')
index d2bb78ebcd1f6b2b24905c01c31a7acad5150240..9f7a97c90affa195c26e5d7b473120412eba5b30 100644 (file)
@@ -74,12 +74,12 @@ static int set_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "--match-set requires two args.");
 
-               if (strlen(argv[optind-1]) > IP_SET_MAXNAMELEN - 1)
+               if (strlen(optarg) > IP_SET_MAXNAMELEN - 1)
                        xtables_error(PARAMETER_PROBLEM,
                                   "setname `%s' too long, max %d characters.",
-                                  argv[optind-1], IP_SET_MAXNAMELEN - 1);
+                                  optarg, IP_SET_MAXNAMELEN - 1);
 
-               get_set_byname(argv[optind - 1], info);
+               get_set_byname(optarg, info);
                parse_bindings(argv[optind], info);
                DEBUGP("parse: set index %u\n", info->index);
                optind++;
index e0e70b62746960527fe1c407ec9cd74f7c83cba5..0068a6e4f0cb18cf9d23fcf0f25e365f27c3e5f8 100644 (file)
@@ -46,12 +46,12 @@ comment_parse(int c, char **argv, int invert, unsigned int *flags,
 
        switch (c) {
        case '1':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
                if (invert) {
                        xtables_error(PARAMETER_PROBLEM,
                                        "Sorry, you can't have an inverted comment");
                }
-               parse_comment(argv[optind-1], commentinfo);
+               parse_comment(optarg, commentinfo);
                *flags = 1;
                break;
 
index 48a79ebb922bcbc0f80bc2ffcef8a523173c07f9..5ebdd340fbe60b202c9510b694928be6c2da07ea 100644 (file)
@@ -55,7 +55,7 @@ connbytes_parse(int c, char **argv, int invert, unsigned int *flags,
                if (xtables_check_inverse(optarg, &invert, &optind, 0, argv))
                        optind++;
 
-               parse_range(argv[optind-1], sinfo);
+               parse_range(optarg, sinfo);
                if (invert) {
                        i = sinfo->count.from;
                        sinfo->count.from = sinfo->count.to;
index 6f24d51b619894ba76402ca29b5f74e0110621b5..a2159158ab68b7dcfac0e7e3b5ad154877dd0884 100644 (file)
@@ -66,7 +66,7 @@ static int connlimit_parse(int c, char **argv, int invert, unsigned int *flags,
                                "--connlimit-above may be given only once");
                *flags |= 0x1;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               info->limit   = strtoul(argv[optind-1], NULL, 0);
+               info->limit   = strtoul(optarg, NULL, 0);
                info->inverse = invert;
                break;
        case 'M':
@@ -75,7 +75,7 @@ static int connlimit_parse(int c, char **argv, int invert, unsigned int *flags,
                                "--connlimit-mask may be given only once");
 
                *flags |= 0x2;
-               i = strtoul(argv[optind-1], &err, 0);
+               i = strtoul(optarg, &err, 0);
                if (family == NFPROTO_IPV6) {
                        if (i > 128 || *err != '\0')
                                xtables_error(PARAMETER_PROBLEM,
index c4be9b17040a60459389a985138e06a21220cd72..d30871fc37584317194e2a6aa1675d94564edb3a 100644 (file)
@@ -300,7 +300,7 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
        case '1':
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
-               parse_states(argv[optind-1], sinfo);
+               parse_states(optarg, sinfo);
                if (invert) {
                        sinfo->invflags |= XT_CONNTRACK_STATE;
                }
@@ -314,10 +314,10 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
                        sinfo->invflags |= XT_CONNTRACK_PROTO;
 
                /* 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;
                sinfo->tuple[IP_CT_DIR_ORIGINAL].dst.protonum =
                        xtables_parse_protocol(protocol);
 
@@ -335,7 +335,7 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
                if (invert)
                        sinfo->invflags |= XT_CONNTRACK_ORIGSRC;
 
-               xtables_ipparse_any(argv[optind-1], &addrs,
+               xtables_ipparse_any(optarg, &addrs,
                                        &sinfo->sipmsk[IP_CT_DIR_ORIGINAL],
                                        &naddrs);
                if(naddrs > 1)
@@ -355,7 +355,7 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
                if (invert)
                        sinfo->invflags |= XT_CONNTRACK_ORIGDST;
 
-               xtables_ipparse_any(argv[optind-1], &addrs,
+               xtables_ipparse_any(optarg, &addrs,
                                        &sinfo->dipmsk[IP_CT_DIR_ORIGINAL],
                                        &naddrs);
                if(naddrs > 1)
@@ -375,7 +375,7 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
                if (invert)
                        sinfo->invflags |= XT_CONNTRACK_REPLSRC;
 
-               xtables_ipparse_any(argv[optind-1], &addrs,
+               xtables_ipparse_any(optarg, &addrs,
                                        &sinfo->sipmsk[IP_CT_DIR_REPLY],
                                        &naddrs);
                if(naddrs > 1)
@@ -395,7 +395,7 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
                if (invert)
                        sinfo->invflags |= XT_CONNTRACK_REPLDST;
 
-               xtables_ipparse_any(argv[optind-1], &addrs,
+               xtables_ipparse_any(optarg, &addrs,
                                        &sinfo->dipmsk[IP_CT_DIR_REPLY],
                                        &naddrs);
                if(naddrs > 1)
@@ -412,7 +412,7 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
        case '7':
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
-               parse_statuses(argv[optind-1], sinfo);
+               parse_statuses(optarg, sinfo);
                if (invert) {
                        sinfo->invflags |= XT_CONNTRACK_STATUS;
                }
@@ -422,7 +422,7 @@ static int conntrack_parse(int c, char **argv, int invert, unsigned int *flags,
        case '8':
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
-               parse_expires(argv[optind-1], sinfo);
+               parse_expires(optarg, sinfo);
                if (invert) {
                        sinfo->invflags |= XT_CONNTRACK_EXPIRES;
                }
index f2beb7f9730c621c10abc35869915f9d44b98d11..8d0b13a268f3a67ba7a114f4dc488d4b938accd5 100644 (file)
@@ -141,7 +141,7 @@ dccp_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "Only one `--source-port' allowed");
                einfo->flags |= XT_DCCP_SRC_PORTS;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_dccp_ports(argv[optind-1], einfo->spts);
+               parse_dccp_ports(optarg, einfo->spts);
                if (invert)
                        einfo->invflags |= XT_DCCP_SRC_PORTS;
                *flags |= XT_DCCP_SRC_PORTS;
@@ -153,7 +153,7 @@ dccp_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "Only one `--destination-port' allowed");
                einfo->flags |= XT_DCCP_DEST_PORTS;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_dccp_ports(argv[optind-1], einfo->dpts);
+               parse_dccp_ports(optarg, einfo->dpts);
                if (invert)
                        einfo->invflags |= XT_DCCP_DEST_PORTS;
                *flags |= XT_DCCP_DEST_PORTS;
@@ -165,7 +165,7 @@ dccp_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "Only one `--dccp-types' allowed");
                einfo->flags |= XT_DCCP_TYPE;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               einfo->typemask = parse_dccp_types(argv[optind-1]);
+               einfo->typemask = parse_dccp_types(optarg);
                if (invert)
                        einfo->invflags |= XT_DCCP_TYPE;
                *flags |= XT_DCCP_TYPE;
@@ -177,7 +177,7 @@ dccp_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "Only one `--dccp-option' allowed");
                einfo->flags |= XT_DCCP_OPTION;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               einfo->option = parse_dccp_option(argv[optind-1]);
+               einfo->option = parse_dccp_option(optarg);
                if (invert)
                        einfo->invflags |= XT_DCCP_OPTION;
                *flags |= XT_DCCP_OPTION;
index 03e47633c059390aa28353d0ce3d65353bb15fde..1569f7d41ecb637afbbc0973dd39733ca7ee8c92 100644 (file)
@@ -83,7 +83,7 @@ dscp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "DSCP match: Only use --dscp ONCE!");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_dscp(argv[optind-1], dinfo);
+               parse_dscp(optarg, dinfo);
                if (invert)
                        dinfo->invert = 1;
                *flags = 1;
@@ -94,7 +94,7 @@ dscp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                        "DSCP match: Only use --dscp-class ONCE!");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_class(argv[optind - 1], dinfo);
+               parse_class(optarg, dinfo);
                if (invert)
                        dinfo->invert = 1;
                *flags = 1;
index 6655ec962df753b9f6a6b36d34aa3e3e8be734b0..18218f476e423a723a0fce1c09948125832fbf42 100644 (file)
@@ -89,7 +89,7 @@ esp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--espspi' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_esp_spis(argv[optind-1], espinfo->spis);
+               parse_esp_spis(optarg, espinfo->spis);
                if (invert)
                        espinfo->invflags |= XT_ESP_INV_SPI;
                *flags |= ESP_SPI;
index 5ff1ae02678732060a943640deed4fd95eb3b07f..a8fe588f429c0f59548159d27e3e01c93a822a6f 100644 (file)
@@ -219,7 +219,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
        case '%':
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit", "--hashlimit",
                          *flags & PARAM_LIMIT);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!parse_rate(optarg, &r->cfg.avg))
                        xtables_error(PARAMETER_PROBLEM,
                                   "bad rate `%s'", optarg);
@@ -229,7 +229,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
        case '$':
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit", "--hashlimit-burst",
                          *flags & PARAM_BURST);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!xtables_strtoui(optarg, NULL, &num, 0, 10000))
                        xtables_error(PARAMETER_PROBLEM,
                                   "bad --hashlimit-burst `%s'", optarg);
@@ -239,7 +239,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
        case '&':
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit", "--hashlimit-htable-size",
                          *flags & PARAM_SIZE);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!xtables_strtoui(optarg, NULL, &num, 0, UINT32_MAX))
                        xtables_error(PARAMETER_PROBLEM,
                                "bad --hashlimit-htable-size: `%s'", optarg);
@@ -249,7 +249,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
        case '*':
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit", "--hashlimit-htable-max",
                          *flags & PARAM_MAX);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!xtables_strtoui(optarg, NULL, &num, 0, UINT32_MAX))
                        xtables_error(PARAMETER_PROBLEM,
                                "bad --hashlimit-htable-max: `%s'", optarg);
@@ -260,7 +260,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit",
                          "--hashlimit-htable-gcinterval",
                          *flags & PARAM_GCINTERVAL);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!xtables_strtoui(optarg, NULL, &num, 0, UINT32_MAX))
                        xtables_error(PARAMETER_PROBLEM,
                                "bad --hashlimit-htable-gcinterval: `%s'", 
@@ -272,7 +272,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
        case ')':
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit",
                          "--hashlimit-htable-expire", *flags & PARAM_EXPIRE);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!xtables_strtoui(optarg, NULL, &num, 0, UINT32_MAX))
                        xtables_error(PARAMETER_PROBLEM,
                                "bad --hashlimit-htable-expire: `%s'", optarg);
@@ -283,7 +283,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
        case '_':
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit", "--hashlimit-mode",
                          *flags & PARAM_MODE);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (parse_mode(&r->cfg.mode, optarg) < 0)
                        xtables_error(PARAMETER_PROBLEM,
                                   "bad --hashlimit-mode: `%s'\n", optarg);
@@ -292,7 +292,7 @@ hashlimit_parse(int c, char **argv, int invert, unsigned int *flags,
        case '"':
                xtables_param_act(XTF_ONLY_ONCE, "hashlimit", "--hashlimit-name",
                          *flags & PARAM_NAME);
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (strlen(optarg) == 0)
                        xtables_error(PARAMETER_PROBLEM, "Zero-length name?");
                strncpy(r->name, optarg, sizeof(r->name));
index 7b049ce1f6342b018990fa6b1675b19124cc66ad..96e8b6cd8e7daf90e8dc8c30a03bf525ca3c8cfd 100644 (file)
@@ -71,7 +71,7 @@ length_parse(int c, char **argv, int invert, unsigned int *flags,
                                           "length: `--length' may only be "
                                           "specified once");
                        xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-                       parse_lengths(argv[optind-1], info);
+                       parse_lengths(optarg, info);
                        if (invert)
                                info->invert = 1;
                        *flags = 1;
index d4baf5f93e2abe5c994abe4dc0f96498bc4cdff7..c836303c6d65cda88e7dd12c9051a52fac94d2f7 100644 (file)
@@ -94,14 +94,14 @@ limit_parse(int c, char **argv, int invert, unsigned int *flags,
 
        switch(c) {
        case '%':
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!parse_rate(optarg, &r->avg))
                        xtables_error(PARAMETER_PROBLEM,
                                   "bad rate `%s'", optarg);
                break;
 
        case '$':
-               if (xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv)) break;
+               if (xtables_check_inverse(optarg, &invert, &optind, 0, argv)) break;
                if (!xtables_strtoui(optarg, NULL, &num, 0, 10000))
                        xtables_error(PARAMETER_PROBLEM,
                                   "bad --limit-burst `%s'", optarg);
index 2722ef00a01b006cfeb89d1706b7aaf83ab0fa8a..00996a0c5ce93ca1349ac6121e98be6cf810690a 100644 (file)
@@ -58,7 +58,7 @@ mac_parse(int c, char **argv, int invert, unsigned int *flags,
        switch (c) {
        case '1':
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_mac(argv[optind-1], macinfo);
+               parse_mac(optarg, macinfo);
                if (invert)
                        macinfo->invert = 1;
                *flags = 1;
index 2be070019c8c00aaf601ff19c1ec2569af40476a..e8a0dab593e3c6dacfc19d20b6ec3fae21a6ca1f 100644 (file)
@@ -164,25 +164,25 @@ __multiport_parse(int c, char **argv, int invert, unsigned int *flags,
 
        switch (c) {
        case '1':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
                proto = check_proto(pnum, invflags);
-               multiinfo->count = parse_multi_ports(argv[optind-1],
+               multiinfo->count = parse_multi_ports(optarg,
                                                     multiinfo->ports, proto);
                multiinfo->flags = XT_MULTIPORT_SOURCE;
                break;
 
        case '2':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
                proto = check_proto(pnum, invflags);
-               multiinfo->count = parse_multi_ports(argv[optind-1],
+               multiinfo->count = parse_multi_ports(optarg,
                                                     multiinfo->ports, proto);
                multiinfo->flags = XT_MULTIPORT_DESTINATION;
                break;
 
        case '3':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
                proto = check_proto(pnum, invflags);
-               multiinfo->count = parse_multi_ports(argv[optind-1],
+               multiinfo->count = parse_multi_ports(optarg,
                                                     multiinfo->ports, proto);
                multiinfo->flags = XT_MULTIPORT_EITHER;
                break;
@@ -231,23 +231,23 @@ __multiport_parse_v1(int c, char **argv, int invert, unsigned int *flags,
 
        switch (c) {
        case '1':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
                proto = check_proto(pnum, invflags);
-               parse_multi_ports_v1(argv[optind-1], multiinfo, proto);
+               parse_multi_ports_v1(optarg, multiinfo, proto);
                multiinfo->flags = XT_MULTIPORT_SOURCE;
                break;
 
        case '2':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
                proto = check_proto(pnum, invflags);
-               parse_multi_ports_v1(argv[optind-1], multiinfo, proto);
+               parse_multi_ports_v1(optarg, multiinfo, proto);
                multiinfo->flags = XT_MULTIPORT_DESTINATION;
                break;
 
        case '3':
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
                proto = check_proto(pnum, invflags);
-               parse_multi_ports_v1(argv[optind-1], multiinfo, proto);
+               parse_multi_ports_v1(optarg, multiinfo, proto);
                multiinfo->flags = XT_MULTIPORT_EITHER;
                break;
 
index bd1076698b01da6a731f612c8e70dc48c5a53205..5382ab60d26246496a9243e767c793f0faaa325b 100644 (file)
@@ -44,7 +44,7 @@ physdev_parse(int c, char **argv, int invert, unsigned int *flags,
                if (*flags & XT_PHYSDEV_OP_IN)
                        goto multiple_use;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               xtables_parse_interface(argv[optind-1], info->physindev,
+               xtables_parse_interface(optarg, info->physindev,
                                (unsigned char *)info->in_mask);
                if (invert)
                        info->invert |= XT_PHYSDEV_OP_IN;
@@ -56,7 +56,7 @@ physdev_parse(int c, char **argv, int invert, unsigned int *flags,
                if (*flags & XT_PHYSDEV_OP_OUT)
                        goto multiple_use;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               xtables_parse_interface(argv[optind-1], info->physoutdev,
+               xtables_parse_interface(optarg, info->physoutdev,
                                (unsigned char *)info->out_mask);
                if (invert)
                        info->invert |= XT_PHYSDEV_OP_OUT;
index b9cb93cc7a36fc9be4f5a185e6064ee09c71e039..cd83e730a6e619fef0dd752542d1f12b82e2388c 100644 (file)
@@ -88,7 +88,7 @@ static int pkttype_parse(int c, char **argv, int invert, unsigned int *flags,
        {
                case '1':
                        xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-                       parse_pkttype(argv[optind-1], info);
+                       parse_pkttype(optarg, info);
                        if(invert)
                                info->invert=1;
                        *flags=1;
index b105529f5f761f736801909d365c4b5b29934191..62100f4bf1d6669d5f7d2df026d17c1bcb9f389e 100644 (file)
@@ -259,7 +259,7 @@ rateest_parse(int c, char **argv, int invert, unsigned int *flags,
                break;
 
        case OPT_RATEEST_EQ:
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
                if (*flags & (1 << c))
                        xtables_error(PARAMETER_PROBLEM,
@@ -272,7 +272,7 @@ rateest_parse(int c, char **argv, int invert, unsigned int *flags,
                break;
 
        case OPT_RATEEST_LT:
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
                if (*flags & (1 << c))
                        xtables_error(PARAMETER_PROBLEM,
@@ -285,7 +285,7 @@ rateest_parse(int c, char **argv, int invert, unsigned int *flags,
                break;
 
        case OPT_RATEEST_GT:
-               xtables_check_inverse(argv[optind-1], &invert, &optind, 0, argv);
+               xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
                if (*flags & (1 << c))
                        xtables_error(PARAMETER_PROBLEM,
index f4844e3f74442bdd529c8adc3bde4c86f8705ab4..441f12e2326c4874147ee8d4e6743640c6346302 100644 (file)
@@ -258,7 +258,7 @@ sctp_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "Only one `--source-port' allowed");
                einfo->flags |= XT_SCTP_SRC_PORTS;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_sctp_ports(argv[optind-1], einfo->spts);
+               parse_sctp_ports(optarg, einfo->spts);
                if (invert)
                        einfo->invflags |= XT_SCTP_SRC_PORTS;
                *flags |= XT_SCTP_SRC_PORTS;
@@ -270,7 +270,7 @@ sctp_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "Only one `--destination-port' allowed");
                einfo->flags |= XT_SCTP_DEST_PORTS;
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_sctp_ports(argv[optind-1], einfo->dpts);
+               parse_sctp_ports(optarg, einfo->dpts);
                if (invert)
                        einfo->invflags |= XT_SCTP_DEST_PORTS;
                *flags |= XT_SCTP_DEST_PORTS;
@@ -288,7 +288,7 @@ sctp_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "--chunk-types requires two args");
 
                einfo->flags |= XT_SCTP_CHUNK_TYPES;
-               parse_sctp_chunks(einfo, argv[optind-1], argv[optind]);
+               parse_sctp_chunks(einfo, optarg, argv[optind]);
                if (invert)
                        einfo->invflags |= XT_SCTP_CHUNK_TYPES;
                optind++;
index 94ef6b741ed3f7d446f52654a1c7cc5549b45cf4..d8159e57e1db755fd6242c879ba25fc5f5c5a17e 100644 (file)
@@ -73,7 +73,7 @@ state_parse(int c, char **argv, int invert, unsigned int *flags,
        case '1':
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
 
-               state_parse_states(argv[optind-1], sinfo);
+               state_parse_states(optarg, sinfo);
                if (invert)
                        sinfo->statemask = ~sinfo->statemask;
                *flags = 1;
index ce2d30d9e74bddfc1160065d4e29b46c818d929d..df6302e811e980b7fc0c85a6c1d12a82286ec54b 100644 (file)
@@ -203,7 +203,7 @@ string_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Can't specify multiple --string");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_string(argv[optind-1], stringinfo);
+               parse_string(optarg, stringinfo);
                if (invert) {
                        if (revision == 0)
                                stringinfo->u.v0.invert = 1;
@@ -219,7 +219,7 @@ string_parse(int c, char **argv, int invert, unsigned int *flags,
                                   "Can't specify multiple --hex-string");
 
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_hex_string(argv[optind-1], stringinfo);  /* sets length */
+               parse_hex_string(optarg, stringinfo);  /* sets length */
                if (invert) {
                        if (revision == 0)
                                stringinfo->u.v0.invert = 1;
index 0f3e27de3aaba1f9d55c077b9b171ec5669d29c7..75551d79bcb6f29ccbc63dd0e7a10c2725a6aa28 100644 (file)
@@ -148,7 +148,7 @@ tcp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--source-port' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_tcp_ports(argv[optind-1], tcpinfo->spts);
+               parse_tcp_ports(optarg, tcpinfo->spts);
                if (invert)
                        tcpinfo->invflags |= XT_TCP_INV_SRCPT;
                *flags |= TCP_SRC_PORTS;
@@ -159,7 +159,7 @@ tcp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--destination-port' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_tcp_ports(argv[optind-1], tcpinfo->dpts);
+               parse_tcp_ports(optarg, tcpinfo->dpts);
                if (invert)
                        tcpinfo->invflags |= XT_TCP_INV_DSTPT;
                *flags |= TCP_DST_PORTS;
@@ -186,7 +186,7 @@ tcp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "--tcp-flags requires two args.");
 
-               parse_tcp_flags(tcpinfo, argv[optind-1], argv[optind],
+               parse_tcp_flags(tcpinfo, optarg, argv[optind],
                                invert);
                optind++;
                *flags |= TCP_FLAGS;
@@ -197,7 +197,7 @@ tcp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--tcp-option' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_tcp_option(argv[optind-1], &tcpinfo->option);
+               parse_tcp_option(optarg, &tcpinfo->option);
                if (invert)
                        tcpinfo->invflags |= XT_TCP_INV_OPTION;
                *flags |= TCP_OPTION;
index 35ddcd6c5f8e601586d2c73b24e6eed548abbc8f..b54a890e7b4343f8a0a75d18ba826b60aefb6ab0 100644 (file)
@@ -66,7 +66,7 @@ tcpmss_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--mss' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_tcp_mssvalues(argv[optind-1],
+               parse_tcp_mssvalues(optarg,
                                    &mssinfo->mss_min, &mssinfo->mss_max);
                if (invert)
                        mssinfo->invert = 1;
index 8e149c1b9e7340ca3542f62ac45735d4211c1d71..9a61c8a5101a34b92fc6dbf8c5585415a46c1e46 100644 (file)
@@ -107,7 +107,7 @@ static int u32_parse(int c, char **argv, int invert, unsigned int *flags,
        struct xt_u32 *data = (void *)(*match)->data;
        unsigned int testind = 0, locind = 0, valind = 0;
        struct xt_u32_test *ct = &data->tests[testind]; /* current test */
-       char *arg = argv[optind-1]; /* the argument string */
+       char *arg = optarg; /* the argument string */
        char *start = arg;
        int state = 0;
 
index 8a80b6e292962d757a9038fa943056af7b26034d..135e7af7b0fe4c76a569d8670cc92bf1a04613e7 100644 (file)
@@ -73,7 +73,7 @@ udp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--source-port' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_udp_ports(argv[optind-1], udpinfo->spts);
+               parse_udp_ports(optarg, udpinfo->spts);
                if (invert)
                        udpinfo->invflags |= XT_UDP_INV_SRCPT;
                *flags |= UDP_SRC_PORTS;
@@ -84,7 +84,7 @@ udp_parse(int c, char **argv, int invert, unsigned int *flags,
                        xtables_error(PARAMETER_PROBLEM,
                                   "Only one `--destination-port' allowed");
                xtables_check_inverse(optarg, &invert, &optind, 0, argv);
-               parse_udp_ports(argv[optind-1], udpinfo->dpts);
+               parse_udp_ports(optarg, udpinfo->dpts);
                if (invert)
                        udpinfo->invflags |= XT_UDP_INV_DSTPT;
                *flags |= UDP_DST_PORTS;
index 36d10e53319b30410aae3039a12bbc93c57cebff..f6daa51c2ad49091d07d7483a51da4e9d5c64e76 100644 (file)
@@ -1497,10 +1497,10 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
                                   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.ipv6.proto = xtables_parse_protocol(protocol);
                        fw.ipv6.flags |= IP6T_F_PROTO;
 
@@ -1521,14 +1521,14 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
                        xtables_check_inverse(optarg, &invert, &optind, argc, argv);
                        set_option(&options, OPT_SOURCE, &fw.ipv6.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.ipv6.invflags,
                                   invert);
-                       dhostnetworkmask = argv[optind-1];
+                       dhostnetworkmask = optarg;
                        break;
 
 #ifdef IP6T_F_GOTO
@@ -1574,7 +1574,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
                        xtables_check_inverse(optarg, &invert, &optind, argc, argv);
                        set_option(&options, OPT_VIANAMEIN, &fw.ipv6.invflags,
                                   invert);
-                       xtables_parse_interface(argv[optind-1],
+                       xtables_parse_interface(optarg,
                                        fw.ipv6.iniface,
                                        fw.ipv6.iniface_mask);
                        break;
@@ -1583,7 +1583,7 @@ int do_command6(int argc, char *argv[], char **table, struct ip6tc_handle **hand
                        xtables_check_inverse(optarg, &invert, &optind, argc, argv);
                        set_option(&options, OPT_VIANAMEOUT, &fw.ipv6.invflags,
                                   invert);
-                       xtables_parse_interface(argv[optind-1],
+                       xtables_parse_interface(optarg,
                                        fw.ipv6.outiface,
                                        fw.ipv6.outiface_mask);
                        break;
index d778c12c2e160aeb2d68ff351c730903c5e58eb5..a69aab3061ee4ce103f95394728d3440e59aac61 100644 (file)
@@ -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;