summaryrefslogtreecommitdiff
path: root/usr.sbin/tcpdump/print-ip.c
diff options
context:
space:
mode:
authorCan Erkin Acar <canacar@cvs.openbsd.org>2005-10-08 19:24:04 +0000
committerCan Erkin Acar <canacar@cvs.openbsd.org>2005-10-08 19:24:04 +0000
commita2441feeb9b96c1fab71f32be1241ad4aa922be2 (patch)
treee4295743559db97ec098ba990551fa922e69eb3f /usr.sbin/tcpdump/print-ip.c
parent83d0ddc7c1a324966b322ba7715de18785466629 (diff)
Check IP version when decoding v4 and v6 packets.
From Jason Wright via PR-4531.
Diffstat (limited to 'usr.sbin/tcpdump/print-ip.c')
-rw-r--r--usr.sbin/tcpdump/print-ip.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c
index a466ae7ef56..120809ee8d3 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: /cvs/OpenBSD/src/usr.sbin/tcpdump/print-ip.c,v 1.28 2004/10/15 11:10:29 markus Exp $ (LBL)";
+ "@(#) $Header: /cvs/OpenBSD/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);