diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2001-03-23 07:14:54 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2001-03-23 07:14:54 +0000 |
commit | 0fc27484c8a2d0548d99fc3c9b49b3ddea8f0233 (patch) | |
tree | 2835fbe0e94ee97b5a8562ed3f123bfd10d29bd5 | |
parent | 00061922644c96b20fec8cc69015cae9d706abf3 (diff) |
check packet length in vlan_input() and pullup if necessary
use m_adj instead of twiddling everything ourselves
-rw-r--r-- | sys/net/if_vlan.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index c64e9c96f7d..f4fa0d49fe2 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.9 2001/03/22 05:26:35 jason Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.10 2001/03/23 07:14:53 jason Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology * @@ -343,6 +343,12 @@ vlan_input(eh, m) struct ifvlan *ifv; u_int tag; + if (m->m_len < EVL_ENCAPLEN && + (m = m_pullup(m, EVL_ENCAPLEN)) == NULL) { + m_freem(m); + return (-1); + } + tag = EVL_VLANOFTAG(ntohs(*mtod(m, u_int16_t *))); for (i = 0; i < NVLAN; i++) { @@ -366,9 +372,7 @@ vlan_input(eh, m) */ m->m_pkthdr.rcvif = &ifv->ifv_if; eh->ether_type = mtod(m, u_int16_t *)[1]; - m->m_data += EVL_ENCAPLEN; - m->m_len -= EVL_ENCAPLEN; - m->m_pkthdr.len -= EVL_ENCAPLEN; + m_adj(m, EVL_ENCAPLEN); #if NBPFILTER > 0 if (ifv->ifv_if.if_bpf) { |