diff options
author | 2005-10-08 19:24:03 +0000 | |
---|---|---|
committer | 2005-10-08 19:24:03 +0000 | |
commit | 6736499f352ff2848bb5dee7859b9c866664e69c (patch) | |
tree | 8a1a8a853421bfd014cef45c6d813f3d6dcc9ba2 | |
parent | If SF_CHIP_AAIP is set then disable AIP to avoid confusing (diff) | |
download | wireguard-openbsd-6736499f352ff2848bb5dee7859b9c866664e69c.tar.xz wireguard-openbsd-6736499f352ff2848bb5dee7859b9c866664e69c.zip |
Check IP version when decoding v4 and v6 packets.
From Jason Wright via PR-4531.
-rw-r--r-- | usr.sbin/tcpdump/print-ip.c | 8 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-ip6.c | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index e912a7c541a..d3d8134c177 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.28 2004/10/15 11:10:29 markus Exp $ */ +/* $OpenBSD: print-ip.c,v 1.29 2005/10/08 19:24:03 canacar 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.28 2004/10/15 11:10:29 markus Exp $ (LBL)"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-ip.c,v 1.29 2005/10/08 19:24:03 canacar Exp $ (LBL)"; #endif #include <sys/param.h> @@ -393,6 +393,10 @@ ip_print(register const u_char *bp, register u_int length) (void)printf("truncated-ip %d", length); return; } + if (ip->ip_v != IPVERSION) { + (void)printf("bad-ip-version %u", ip->ip_v); + return; + } hlen = ip->ip_hl * 4; if (hlen < sizeof(struct ip)) { (void)printf("bad-hlen %d", hlen); diff --git a/usr.sbin/tcpdump/print-ip6.c b/usr.sbin/tcpdump/print-ip6.c index 79dc408e0fe..c05cabeb840 100644 --- a/usr.sbin/tcpdump/print-ip6.c +++ b/usr.sbin/tcpdump/print-ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-ip6.c,v 1.5 2004/02/04 08:35:12 otto Exp $ */ +/* $OpenBSD: print-ip6.c,v 1.6 2005/10/08 19:24:03 canacar Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 @@ -100,6 +100,10 @@ ip6_print(register const u_char *bp, register int length) (void)printf("truncated-ip6 %d", length); return; } + if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) { + (void)printf("bad-ip6-version %u", ip6->ip6_vfc >> 4); + return; + } hlen = sizeof(struct ip6_hdr); len = ntohs(ip6->ip6_plen); |