summaryrefslogtreecommitdiff
path: root/print-ip.c
diff options
context:
space:
mode:
authoritojun <itojun>2000-05-10 05:11:27 +0000
committeritojun <itojun>2000-05-10 05:11:27 +0000
commit491f3cbf582e1101ba965144151ea7e6c6c55820 (patch)
tree762b27df57fe6a89b681aec2558fd7c9e11a8d7b /print-ip.c
parent7fd1be1520c42204a6c7ec62ba34b1dd7b0884bb (diff)
downloadtcpdump-491f3cbf582e1101ba965144151ea7e6c6c55820.tar.gz
correct handling of truncated IPv4 option.
Diffstat (limited to 'print-ip.c')
-rw-r--r--print-ip.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/print-ip.c b/print-ip.c
index 09ae8105..0d86de55 100644
--- a/print-ip.c
+++ b/print-ip.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.81 2000-05-01 17:35:45 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.82 2000-05-10 05:11:27 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -299,7 +299,15 @@ ip_optprint(register const u_char *cp, u_int length)
for (; length > 0; cp += len, length -= len) {
int tt = *cp;
- len = (tt == IPOPT_NOP || tt == IPOPT_EOL) ? 1 : cp[1];
+ if (tt == IPOPT_NOP || tt == IPOPT_EOL)
+ len = 1;
+ else {
+ if (&cp[1] >= snapend) {
+ printf("[|ip]");
+ return;
+ }
+ len = cp[1];
+ }
if (len <= 0) {
printf("[|ip op len %d]", len);
return;