summaryrefslogtreecommitdiffstats
path: root/ip6tables.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2002-03-14 11:35:58 +0000
committerHarald Welte <laforge@gnumonks.org>2002-03-14 11:35:58 +0000
commitb77f1dafb9f35752bb9685323bcacb32a0e6ddc5 (patch)
tree32821b41042796995881aabc74f6821e7603b288 /ip6tables.c
parentdffa8ddb43ca2d5bfe7344daea2f6e80c5adaa58 (diff)
Fix 'iptables -p !' bug (segfault when `!' used without argument)
Diffstat (limited to 'ip6tables.c')
-rw-r--r--ip6tables.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/ip6tables.c b/ip6tables.c
index 22d636eb..b4d6ea55 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -424,14 +424,20 @@ add_command(int *cmd, const int newcmd, const int othercmds, int invert)
}
int
-check_inverse(const char option[], int *invert)
+check_inverse(const char option[], int *invert, int *optind, int argc)
{
if (option && strcmp(option, "!") == 0) {
if (*invert)
exit_error(PARAMETER_PROBLEM,
"Multiple `!' flags not allowed");
-
*invert = TRUE;
+ if (optind) {
+ *optind = *optind+1;
+ if (argc && *optind > argc)
+ exit_error(PARAMETER_PROBLEM,
+ "no argument following `!'");
+ }
+
return TRUE;
}
return FALSE;
@@ -1838,8 +1844,7 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
* Option selection
*/
case 'p':
- if (check_inverse(optarg, &invert))
- optind++;
+ check_inverse(optarg, &invert, &optind, argc);
set_option(&options, OPT_PROTOCOL, &fw.ipv6.invflags,
invert);
@@ -1861,8 +1866,7 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
break;
case 's':
- if (check_inverse(optarg, &invert))
- optind++;
+ check_inverse(optarg, &invert, &optind, argc);
set_option(&options, OPT_SOURCE, &fw.ipv6.invflags,
invert);
shostnetworkmask = argv[optind-1];
@@ -1870,8 +1874,7 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
break;
case 'd':
- if (check_inverse(optarg, &invert))
- optind++;
+ check_inverse(optarg, &invert, &optind, argc);
set_option(&options, OPT_DESTINATION, &fw.ipv6.invflags,
invert);
dhostnetworkmask = argv[optind-1];
@@ -1901,8 +1904,7 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
case 'i':
- if (check_inverse(optarg, &invert))
- optind++;
+ check_inverse(optarg, &invert, &optind, argc);
set_option(&options, OPT_VIANAMEIN, &fw.ipv6.invflags,
invert);
parse_interface(argv[optind-1],
@@ -1912,8 +1914,7 @@ int do_command6(int argc, char *argv[], char **table, ip6tc_handle_t *handle)
break;
case 'o':
- if (check_inverse(optarg, &invert))
- optind++;
+ check_inverse(optarg, &invert, &optind, argc);
set_option(&options, OPT_VIANAMEOUT, &fw.ipv6.invflags,
invert);
parse_interface(argv[optind-1],