From d227658f6b993a96be8b3e7c775a068356d62842 Mon Sep 17 00:00:00 2001 From: is Date: Sun, 10 Dec 2006 14:39:03 +0000 Subject: [PATCH] Avoid overlapping struct assignment, like in the Ethernet and FDDI cases. --- sys/net/if_tokensubr.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/sys/net/if_tokensubr.c b/sys/net/if_tokensubr.c index adbdcd8d17d4..bcdcac8ac2fd 100644 --- a/sys/net/if_tokensubr.c +++ b/sys/net/if_tokensubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_tokensubr.c,v 1.39 2006/09/07 02:40:33 dogcow Exp $ */ +/* $NetBSD: if_tokensubr.c,v 1.40 2006/12/10 14:39:03 is Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -99,7 +99,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.39 2006/09/07 02:40:33 dogcow Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.40 2006/12/10 14:39:03 is Exp $"); #include "opt_inet.h" #include "opt_atalk.h" @@ -512,9 +512,9 @@ token_input(struct ifnet *ifp, struct mbuf *m) trrif = TOKEN_RIF(trh); lan_hdr_len += (ntohs(trrif->tr_rcf) & TOKEN_RCF_LEN_MASK) >> 8; } - m_adj(m, lan_hdr_len); - l = mtod(m, struct llc *); + l = (struct llc *)(mtod(m, u_int8_t *) + lan_hdr_len); + switch (l->llc_dsap) { #if defined(INET) || defined(NS) || defined(DECNET) case LLC_SNAP_LSAP: @@ -527,7 +527,7 @@ token_input(struct ifnet *ifp, struct mbuf *m) l->llc_snap.org_code[2] != 0) goto dropanyway; etype = ntohs(l->llc_snap.ether_type); - m_adj(m, LLC_SNAPFRAMELEN); + m_adj(m, lan_hdr_len + LLC_SNAPFRAMELEN); #if NCARP > 0 if (ifp->if_carp && ifp->if_type != IFT_CARP && (carp_input(m, (u_int8_t *)&trh->token_shost, @@ -570,14 +570,7 @@ token_input(struct ifnet *ifp, struct mbuf *m) /* LLC_UI_P forbidden in class 1 service */ if ((l->llc_dsap == LLC_ISO_LSAP) && (l->llc_ssap == LLC_ISO_LSAP)) { - /* LSAP for ISO */ - m->m_data += 3; /* XXX */ - m->m_len -= 3; /* XXX */ - m->m_pkthdr.len -= 3; /* XXX */ - M_PREPEND(m, sizeof *trh, M_DONTWAIT); - if (m == 0) - return; - *mtod(m, struct token_header *) = *trh; + #if defined(__FreeBSD__) IFDEBUG(D_ETHER) printf("clnp packet");