Skip to contentSkip to conversation

disallow multiple matches of same type

PATCH In review Phil Oester 3 participants 4 messages Feb 20, 2006 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 disallow multiple matches of same type

In latest iptables SVN, the command:

iptables -A foo -p tcp -m multiport --dport 45,47 -m multiport --sport 45:48

ends up with mangled results of:

... multiport sports multiport sports tcp spts:45:48

Since at present, iptables can only handle one match of a given type per rule. The below patch makes sure we disallow more than one.

This closes bugzilla #447

Phil

iptables.c +5 -0
@@ -2125,6 +2125,11 @@
 				exit_error(PARAMETER_PROBLEM,
 					   "unexpected ! flag before --match");
 
+			for (matchp = matches; matchp; matchp = matchp->next) {
+				if (strcmp(optarg, matchp->match->name) == 0)
+					exit_error(PARAMETER_PROBLEM,
+						   "multiple matches of same type not supported");
+			}
 			m = find_match(optarg, LOAD_MUST_SUCCEED, &matches);
 			size = IPT_ALIGN(sizeof(struct ipt_entry_match))
 					 + m->size;
#1 lore raw
Quoted 4 lines · Phil Oester

In latest iptables SVN, the command:

iptables -A foo -p tcp -m multiport --dport 45,47 -m multiport --sport 45:48

Quoted 8 lines

ends up with mangled results of:

... multiport sports multiport sports tcp spts:45:48

Since at present, iptables can only handle one match of a given type per rule. The below patch makes sure we disallow more than one.

This closes bugzilla #447

I think Harald already did something in this direction. Harald?

#2 lore raw
Quoted 1 line · Patrick McHardy

I think Harald already did something in this direction. Harald?

He corrected it so iptables didn't segfault, and opened a new bug for the incorrect behaviour. This fixes that new bug.

Phil

#3 lore raw
Quoted 5 lines · Phil Oester
Quoted 1 line · Patrick McHardy

I think Harald already did something in this direction. Harald?

He corrected it so iptables didn't segfault, and opened a new bug for the incorrect behaviour. This fixes that new bug.

that's correct. Haven't reviewed your bugfix yet, though.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie