diff options
author | itojun <itojun> | 2000-05-10 05:11:27 +0000 |
---|---|---|
committer | itojun <itojun> | 2000-05-10 05:11:27 +0000 |
commit | 491f3cbf582e1101ba965144151ea7e6c6c55820 (patch) | |
tree | 762b27df57fe6a89b681aec2558fd7c9e11a8d7b /print-ip.c | |
parent | 7fd1be1520c42204a6c7ec62ba34b1dd7b0884bb (diff) | |
download | tcpdump-491f3cbf582e1101ba965144151ea7e6c6c55820.tar.gz |
correct handling of truncated IPv4 option.
Diffstat (limited to 'print-ip.c')
-rw-r--r-- | print-ip.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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; |