diff options
author | Can Erkin Acar <canacar@cvs.openbsd.org> | 2007-06-27 18:15:26 +0000 |
---|---|---|
committer | Can Erkin Acar <canacar@cvs.openbsd.org> | 2007-06-27 18:15:26 +0000 |
commit | cc1573a47c344138c21b5ac5ff3b35b06b2d0267 (patch) | |
tree | 34d56b774614047ece2bc586517acabcbef0381a /usr.sbin/tcpdump/print-atalk.c | |
parent | 90ed0d1897431034355c3e2f3a7f77f80049772b (diff) |
When aligning buffers correctly handle the case where the
buffers overlap, which happens on 64 bit archs, when
handling encapsulated packets. Reported and tested by Jurjen Oskam
additional testing by Stuart Henderson and todd@, ok henning@
Diffstat (limited to 'usr.sbin/tcpdump/print-atalk.c')
-rw-r--r-- | usr.sbin/tcpdump/print-atalk.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/tcpdump/print-atalk.c b/usr.sbin/tcpdump/print-atalk.c index b52240788cd..a0474ce4174 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.23 2004/02/04 08:35:12 otto Exp $ */ +/* $OpenBSD: print-atalk.c,v 1.24 2007/06/27 18:15:25 canacar 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.23 2004/02/04 08:35:12 otto Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-atalk.c,v 1.24 2007/06/27 18:15:25 canacar Exp $ (LBL)"; #endif #include <sys/param.h> @@ -226,14 +226,17 @@ ddp_print(register const u_char *bp, register u_int length, register int t, if ((intptr_t)bp & (sizeof(long)-1)) { static u_char *abuf = NULL; + int clen = snapend - bp; + if (clen > snaplen) + clen = snaplen; if (abuf == NULL) { abuf = (u_char *)malloc(snaplen); if (abuf == NULL) error("ddp_print: malloc"); } - memcpy(abuf, bp, min(length, snaplen)); - snapend += abuf - bp; + memmove((char *)abuf, (char *)bp, min(length, clen)); + snapend = abuf + clen; packetp = abuf; bp = abuf; } |