diff options
| author | Robert Watson <rwatson@FreeBSD.org> | 2000-03-11 00:24:29 +0000 |
|---|---|---|
| committer | Robert Watson <rwatson@FreeBSD.org> | 2000-03-11 00:24:29 +0000 |
| commit | 76ec7b2f60d71178c90c08964481b9bdeb5c279a (patch) | |
| tree | cdb19e24cebdf885ab4089eecc03d5fe84808a0b | |
| parent | c63d4e17ae309c1650612c20492592a0bf4e1359 (diff) | |
Notes
| -rw-r--r-- | sys/netinet/if_ether.c | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index c87b72dc3268..00bfb84b66c8 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -430,9 +430,9 @@ arpresolve(ac, rt, m, dst, desten, rt0) static void arpintr() { - register struct mbuf *m; + register struct mbuf *m, *m0; register struct arphdr *ar; - int s; + int s, ml; while (arpintrq.ifq_head) { s = splimp(); @@ -440,21 +440,44 @@ arpintr() splx(s); if (m == 0 || (m->m_flags & M_PKTHDR) == 0) panic("arpintr"); - if (m->m_len >= sizeof(struct arphdr) && - (ar = mtod(m, struct arphdr *)) && - (ntohs(ar->ar_hrd) == ARPHRD_ETHER || - ntohs(ar->ar_hrd) == ARPHRD_IEEE802) && - m->m_len >= - sizeof(struct arphdr) + 2 * ar->ar_hln + 2 * ar->ar_pln) + + if (m->m_len < sizeof(struct arphdr) && + (m = m_pullup(m, sizeof(struct arphdr)) == NULL)) { + log(LOG_ERR, "arp: runt packet -- m_pullup failed."); + continue; + } + ar = mtod(m, struct arphdr *); + + if (ntohs(ar->ar_hrd) != ARPHRD_ETHER + && ntohs(ar->ar_hrd) != ARPHRD_IEEE802) { + log(LOG_ERR, + "arp: unknown hardware address format (%2D)", + (unsigned char *)&ar->ar_hrd, ""); + m_freem(m); + continue; + } - switch (ntohs(ar->ar_pro)) { + m0 = m; + ml = 0; + while (m0 != NULL) { + ml += m0->m_len; /* wanna implement m_size?? */ + m0 = m0->m_next; + } + + if (ml < sizeof(struct arphdr) + 2 * ar->ar_hln + + 2 * ar->ar_pln) { + log(LOG_ERR, "arp: runt packet."); + m_freem(m); + continue; + } + switch (ntohs(ar->ar_pro)) { #ifdef INET - case ETHERTYPE_IP: - in_arpinput(m); - continue; + case ETHERTYPE_IP: + in_arpinput(m); + continue; #endif - } + } m_freem(m); } } |
