Module Name:    src
Committed By:   maxv
Date:           Tue Feb 13 10:31:01 UTC 2018

Modified Files:
        src/sys/netinet: if_arp.c

Log Message:
Same change as rev1.258, but this time in revarpinput: use m_pullup.


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/sys/netinet/if_arp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.262 src/sys/netinet/if_arp.c:1.263
--- src/sys/netinet/if_arp.c:1.262	Tue Feb 13 10:20:50 2018
+++ src/sys/netinet/if_arp.c	Tue Feb 13 10:31:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.262 2018/02/13 10:20:50 maxv Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.263 2018/02/13 10:31:01 maxv Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.262 2018/02/13 10:20:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.263 2018/02/13 10:31:01 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1820,16 +1820,18 @@ void
 revarpinput(struct mbuf *m)
 {
 	struct arphdr *ar;
+	int arplen;
 
-	if (m->m_len < sizeof(struct arphdr))
-		goto out;
+	arplen = sizeof(struct arphdr);
+	if (m->m_len < arplen && (m = m_pullup(m, arplen)) == NULL)
+		return;
 	ar = mtod(m, struct arphdr *);
-#if 0 /* XXX I don't think we need this... and it will prevent other LL */
-	if (ntohs(ar->ar_hrd) != ARPHRD_ETHER)
-		goto out;
-#endif
-	if (m->m_len < sizeof(struct arphdr) + 2 * (ar->ar_hln + ar->ar_pln))
-		goto out;
+
+	arplen = sizeof(struct arphdr) + 2 * (ar->ar_hln + ar->ar_pln);
+	if (m->m_len < arplen && (m = m_pullup(m, arplen)) == NULL)
+		return;
+	ar = mtod(m, struct arphdr *);
+
 	switch (ntohs(ar->ar_pro)) {
 	case ETHERTYPE_IP:
 	case ETHERTYPE_IPTRAILERS:
@@ -1839,7 +1841,7 @@ revarpinput(struct mbuf *m)
 	default:
 		break;
 	}
-out:
+
 	m_freem(m);
 }
 

Reply via email to