summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-04-15 16:04:10 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-04-15 16:04:10 +0200
commited4be04b8fd80e8c47727191ee7385f418587652 (patch)
treee8a0adaa63d4c58ff53c402d9a684f0595201913
parent0ad97454e708a7f0ca0db36c2b90d1ae6c74ae30 (diff)
downloadmodquicktun-ed4be04b8fd80e8c47727191ee7385f418587652.tar
modquicktun-ed4be04b8fd80e8c47727191ee7385f418587652.zip
Drop short packages
-rw-r--r--quicktun.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/quicktun.c b/quicktun.c
index 6899a05..4c5c585 100644
--- a/quicktun.c
+++ b/quicktun.c
@@ -2,6 +2,7 @@
#include <linux/ethtool.h>
#include <linux/if_arp.h>
#include <linux/ip.h>
+#include <linux/ipv6.h>
#include <linux/netdevice.h>
#include <linux/udp.h>
#include <net/dst.h>
@@ -101,10 +102,15 @@ static void quicktun_udp_data_ready(struct sock *sk, int bytes)
switch (tun->flags & QUICKTUN_MODE_MASK) {
case QUICKTUN_MODE_ETHERNET:
+ if (len < ETH_HLEN)
+ goto drop;
skb->protocol = eth_type_trans(skb, tun->dev);
break;
case QUICKTUN_MODE_IP:
+ if (len < sizeof(struct iphdr))
+ goto drop;
+
__skb_tunnel_rx(skb, tun->dev);
skb_reset_network_header(skb);
@@ -113,6 +119,8 @@ static void quicktun_udp_data_ready(struct sock *sk, int bytes)
skb->protocol = htons(ETH_P_IP);
break;
case 0x60:
+ if (len < sizeof(struct ipv6hdr))
+ goto drop;
skb->protocol = htons(ETH_P_IPV6);
break;
default:
@@ -135,8 +143,7 @@ static void quicktun_udp_data_ready(struct sock *sk, int bytes)
kfree_skb(skb);
}
-static int
-quicktun_net_change_mtu(struct net_device *dev, int new_mtu)
+static int quicktun_net_change_mtu(struct net_device *dev, int new_mtu)
{
if (new_mtu < MIN_MTU || new_mtu + dev->hard_header_len > MAX_MTU)
return -EINVAL;