diff options
author | 2002-04-10 10:22:59 +0000 | |
---|---|---|
committer | 2002-04-10 10:22:59 +0000 | |
commit | cbc824f5f136fb86f9c559fbd44e89ff9c546018 (patch) | |
tree | 8a833f8da9703f245bc46d90cd9135da403a2ed8 | |
parent | Clean up after pw_file(). (diff) | |
download | wireguard-openbsd-cbc824f5f136fb86f9c559fbd44e89ff9c546018.tar.xz wireguard-openbsd-cbc824f5f136fb86f9c559fbd44e89ff9c546018.zip |
If the IP header length is zero, the packet will loop in ip_print().
Taken from tcpdump 3.7.1; mbing@nfr.net; ho ok
-rw-r--r-- | usr.sbin/tcpdump/print-ip.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index 374a8c27ef2..3f1f975b1a8 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.15 2001/02/15 16:16:48 niklas Exp $ */ +/* $OpenBSD: print-ip.c,v 1.16 2002/04/10 10:22:59 deraadt Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-ip.c,v 1.15 2001/02/15 16:16:48 niklas Exp $ (LBL)"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-ip.c,v 1.16 2002/04/10 10:22:59 deraadt Exp $ (LBL)"; #endif #include <sys/param.h> @@ -394,6 +394,10 @@ ip_print(register const u_char *bp, register u_int length) return; } hlen = ip->ip_hl * 4; + if (hlen < sizeof(struct ip)) { + (void)printf("bad-hlen %d", hlen); + return; + } len = ntohs(ip->ip_len); if (length < len) |