Skip to contentSkip to conversation

netfilter: ipset: add missing break statemtns in ip_set_get_ip_port()

PATCH Patrick McHardy 2 participants 2 messages Feb 2, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Add missing break statements.

I assume the second switch statement which handles only TCP and UDP is intended to indicate whether a real port number instead of ICMP port and code were parsed? Otherwise we should add IPPROTO_ICMP and IPPROTO_ICMPV6 there too.

commit 316ed388802533bcfd3dffb38d2ba29ac5428456

Author: Patrick McHardy <[email protected]>
Date:   Wed Feb 2 09:31:37 2011 +0100

netfilter: ipset: add missing break statemtns in ip_set_get_ip_port()

Don't fall through in the switch statement, otherwise IPv4 headers are incorrectly parsed again as IPv6 and the return value will always be 'false'.

net/netfilter/ipset/ip_set_getport.c +2 -0
index 76737bb..4dd2785 100644
@@ -118,8 +118,10 @@ ip_set_get_ip_port(const struct sk_buff *skb, u8 pf, bool src, __be16 *port)
 	switch (pf) {
 	case AF_INET:
 		ret = ip_set_get_ip4_port(skb, src, port, &proto);
+		break;
 	case AF_INET6:
 		ret = ip_set_get_ip6_port(skb, src, port, &proto);
+		break;
 	default:
 		return false;
 	}
#1 lore raw
Quoted 1 line · Patrick McHardy

Add missing break statements.

Thanks! It's a clear bugfix, I applied your patch.

Quoted 4 lines

I assume the second switch statement which handles only TCP and UDP is intended to indicate whether a real port number instead of ICMP port and code were parsed? Otherwise we should add IPPROTO_ICMP and IPPROTO_ICMPV6 there too.

Yes, excatly. The function is called from the bitmap:port type which can handle TCP/UDP ports only.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary