浏览代码

ndisc: Check NS message length before access.

Check message length before accessing "target" field,
as we do for other types.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
YOSHIFUJI Hideaki / 吉藤英明 12 年之前
父节点
当前提交
115b0aa6b4
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      net/ipv6/ndisc.c

+ 5 - 0
net/ipv6/ndisc.c

@@ -671,6 +671,11 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	bool inc;
 	bool inc;
 	int is_router = -1;
 	int is_router = -1;
 
 
+	if (skb->len < sizeof(struct nd_msg)) {
+		ND_PRINTK(2, warn, "NS: packet too short\n");
+		return;
+	}
+
 	if (ipv6_addr_is_multicast(&msg->target)) {
 	if (ipv6_addr_is_multicast(&msg->target)) {
 		ND_PRINTK(2, warn, "NS: multicast target address\n");
 		ND_PRINTK(2, warn, "NS: multicast target address\n");
 		return;
 		return;