Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Same change as rev1.258, but this time in revarp...



details:   https://anonhg.NetBSD.org/src/rev/cf55eb681683
branches:  trunk
changeset: 829813:cf55eb681683
user:      maxv <maxv%NetBSD.org@localhost>
date:      Tue Feb 13 10:31:01 2018 +0000

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

diffstat:

 sys/netinet/if_arp.c |  24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diffs (54 lines):

diff -r ffb1ffeabbd7 -r cf55eb681683 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Tue Feb 13 10:20:50 2018 +0000
+++ b/sys/netinet/if_arp.c      Tue Feb 13 10:31:01 2018 +0000
@@ -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 @@
 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 @@
        default:
                break;
        }
-out:
+
        m_freem(m);
 }
 



Home | Main Index | Thread Index | Old Index