diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-02-02 09:43:28 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2004-02-02 09:43:28 +0000 |
commit | beb20b29475cf9d4a3a6311a67ec1004408304fc (patch) | |
tree | 97ef010a6cb664154f922e4d544610c3fb59c3af /usr.sbin/tcpdump | |
parent | 009bf16b1839115da8a6bc4bcf37470dc1d238eb (diff) |
Do away with non-aligned memory accesses.
ok deraadt@ hshoexer@
Diffstat (limited to 'usr.sbin/tcpdump')
-rw-r--r-- | usr.sbin/tcpdump/Makefile | 6 | ||||
-rw-r--r-- | usr.sbin/tcpdump/addrtoname.c | 9 | ||||
-rw-r--r-- | usr.sbin/tcpdump/extract.h | 10 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-atalk.c | 6 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-ip.c | 9 |
5 files changed, 12 insertions, 28 deletions
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile index 31340fc215c..50bc705e4b1 100644 --- a/usr.sbin/tcpdump/Makefile +++ b/usr.sbin/tcpdump/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.44 2004/01/31 15:13:03 otto Exp $ +# $OpenBSD: Makefile,v 1.45 2004/02/02 09:43:27 otto Exp $ # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 # The Regents of the University of California. All rights reserved. @@ -26,10 +26,6 @@ MAN= tcpdump.8 CFLAGS+=-Wall -I${.CURDIR}/../../sbin/pfctl CFLAGS+=-DCSLIP -DPPP -DHAVE_FDDI -DETHER_SERVICE -DRETSIGTYPE=void -DHAVE_NET_SLIP_H -DHAVE_ETHER_NTOHOST -DINET6 -.if (${MACHINE_ARCH} == "alpha") || (${MACHINE_ARCH} == "sparc") || \ - (${MACHINE_ARCH} == "sparc64") -CFLAGS+=-DLBL_ALIGN -.endif LDADD+= -lpcap -ll -lcrypto DPADD+= ${LIBL} ${LIBPCAP} ${LIBCRYPTO} diff --git a/usr.sbin/tcpdump/addrtoname.c b/usr.sbin/tcpdump/addrtoname.c index 9aa41982f97..087e84fef5d 100644 --- a/usr.sbin/tcpdump/addrtoname.c +++ b/usr.sbin/tcpdump/addrtoname.c @@ -1,4 +1,4 @@ -/* $OpenBSD: addrtoname.c,v 1.21 2004/01/31 15:13:03 otto Exp $ */ +/* $OpenBSD: addrtoname.c,v 1.22 2004/02/02 09:43:27 otto Exp $ */ /* * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -25,7 +25,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.c,v 1.21 2004/01/31 15:13:03 otto Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/addrtoname.c,v 1.22 2004/02/02 09:43:27 otto Exp $ (LBL)"; #endif #include <sys/types.h> @@ -166,9 +166,6 @@ getname(const u_char *ap) u_int32_t addr; struct hnamemem *p; -#ifndef LBL_ALIGN - addr = *(const u_int32_t *)ap; -#else /* * Extract 32 bits in network order, dealing with alignment. */ @@ -202,7 +199,7 @@ getname(const u_char *ap) #endif break; } -#endif + p = &hnametable[addr & (HASHNAMESIZE-1)]; for (; p->nxt; p = p->nxt) { if (p->addr == addr) diff --git a/usr.sbin/tcpdump/extract.h b/usr.sbin/tcpdump/extract.h index cecfb342759..4a8d9e8f8ac 100644 --- a/usr.sbin/tcpdump/extract.h +++ b/usr.sbin/tcpdump/extract.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extract.h,v 1.7 2002/09/03 12:21:12 ho Exp $ */ +/* $OpenBSD: extract.h,v 1.8 2004/02/02 09:43:27 otto Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995, 1996 @@ -25,21 +25,15 @@ /* Network to host order macros */ -#ifdef LBL_ALIGN #define EXTRACT_16BITS(p) \ ((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ (u_int16_t)*((const u_int8_t *)(p) + 1)) + #define EXTRACT_32BITS(p) \ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ (u_int32_t)*((const u_int8_t *)(p) + 3)) -#else -#define EXTRACT_16BITS(p) \ - ((u_int16_t)ntohs(*(const u_int16_t *)(p))) -#define EXTRACT_32BITS(p) \ - ((u_int32_t)ntohl(*(const u_int32_t *)(p))) -#endif #define EXTRACT_24BITS(p) \ ((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c index 4ee1e80f8e4..403b1958bc9 100644 --- a/usr.sbin/tcpdump/print-atalk.c +++ b/usr.sbin/tcpdump/print-atalk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-atalk.c,v 1.21 2004/01/28 19:44:55 canacar Exp $ */ +/* $OpenBSD: print-atalk.c,v 1.22 2004/02/02 09:43:27 otto Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-atalk.c,v 1.21 2004/01/28 19:44:55 canacar Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-atalk.c,v 1.22 2004/02/02 09:43:27 otto Exp $ (LBL)"; #endif #include <sys/param.h> @@ -223,7 +223,6 @@ ddp_print(register const u_char *bp, register u_int length, register int t, register u_short snet, register u_char snode, u_char skt) { -#ifdef LBL_ALIGN if ((long)bp & 3) { static u_char *abuf = NULL; @@ -237,7 +236,6 @@ ddp_print(register const u_char *bp, register u_int length, register int t, packetp = abuf; bp = abuf; } -#endif switch (t) { diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index 0f9d92b21c5..ad025421e17 100644 --- a/usr.sbin/tcpdump/print-ip.c +++ b/usr.sbin/tcpdump/print-ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ip.c,v 1.22 2004/01/21 06:15:18 mcbride Exp $ */ +/* $OpenBSD: print-ip.c,v 1.23 2004/02/02 09:43:27 otto Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.22 2004/01/21 06:15:18 mcbride Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.23 2004/02/02 09:43:27 otto Exp $ (LBL)"; #endif #include <sys/param.h> @@ -359,10 +359,9 @@ ip_print(register const u_char *bp, register u_int length) register const u_char *cp; ip = (const struct ip *)bp; -#ifdef LBL_ALIGN /* * If the IP header is not aligned, copy into abuf. - * This will never happen with BPF. It does happen raw packet + * This will never happen with BPF. It does happen with raw packet * dumps from -r. */ if ((long)ip & 3) { @@ -384,7 +383,7 @@ ip_print(register const u_char *bp, register u_int length) ++didwarn; } } -#endif + if ((u_char *)(ip + 1) > snapend) { printf("[|ip]"); return; |