diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-04-10 10:23:00 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-04-10 10:23:00 +0000 |
commit | b9780a0ea9e74ce401eb965f686bed2ed8a35769 (patch) | |
tree | a84e164a754dcd5fb6e3be1ea48625cc58f68b98 /usr.sbin/tcpdump/print-ip.c | |
parent | bb1f2d2b3fc05734a05223039052ebb87615f22a (diff) |
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
Diffstat (limited to 'usr.sbin/tcpdump/print-ip.c')
-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 b96e0fd7030..15ea80e0cf3 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: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.15 2001/02/15 16:16:48 niklas Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/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) |