summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>2004-10-21 01:33:37 +0200
committerPatrick McHardy <kaber@coreworks.de>2004-10-21 01:33:37 +0200
commit2a00d1ba2b45f614369686edeeec5760932437d2 (patch)
tree523630c9ce829d5c43c21cd24888893bd2878a8f
parent2afe6f85921307c4eb674364f133afc93169ecdd (diff)
[NETFILTER]: Enable ip6t_multiport.c to work without skb_linearize()
Signed-off-by: Yasuyuki KOZAKAI <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--net/ipv6/netfilter/ip6t_multiport.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/net/ipv6/netfilter/ip6t_multiport.c b/net/ipv6/netfilter/ip6t_multiport.c
index 3b38c8449b30..6e3246153fa3 100644
--- a/net/ipv6/netfilter/ip6t_multiport.c
+++ b/net/ipv6/netfilter/ip6t_multiport.c
@@ -56,24 +56,29 @@ match(const struct sk_buff *skb,
unsigned int protoff,
int *hotdrop)
{
- const struct udphdr *udp = (const struct udphdr *)(skb->data + protoff);
+ u16 _ports[2], *pptr;
const struct ip6t_multiport *multiinfo = matchinfo;
- /* Must be big enough to read ports. */
- if (offset == 0 && skb->len - protoff < sizeof(struct udphdr)) {
+ /* Must not be a fragment. */
+ if (offset)
+ return 0;
+
+ /* Must be big enough to read ports (both UDP and TCP have
+ them at the start). */
+ pptr = skb_header_pointer(skb, protoff, sizeof(_ports), &_ports[0]);
+ if (pptr == NULL) {
/* We've been asked to examine this packet, and we
- can't. Hence, no choice but to drop. */
- duprintf("ip6t_multiport:"
- " Dropping evil offset=0 tinygram.\n");
- *hotdrop = 1;
- return 0;
+ * can't. Hence, no choice but to drop.
+ */
+ duprintf("ip6t_multiport:"
+ " Dropping evil offset=0 tinygram.\n");
+ *hotdrop = 1;
+ return 0;
}
- /* Must not be a fragment. */
- return !offset
- && ports_match(multiinfo->ports,
- multiinfo->flags, multiinfo->count,
- ntohs(udp->source), ntohs(udp->dest));
+ return ports_match(multiinfo->ports,
+ multiinfo->flags, multiinfo->count,
+ ntohs(pptr[0]), ntohs(pptr[1]));
}
/* Called when user tries to insert an entry of this type. */