diff options
author | Pedro F. Giffuni <pfg@FreeBSD.org> | 2015-01-27 01:39:42 +0000 |
---|---|---|
committer | Pedro F. Giffuni <pfg@FreeBSD.org> | 2015-01-27 01:39:42 +0000 |
commit | aae6b2073aeb7ba1118183bb52286e44dd04df28 (patch) | |
tree | 954097735ef4ceb518d8bda369e0af5b5f0c2d18 | |
parent | e91eac244982a8728f370000c353b16e18174ec9 (diff) | |
download | src-aae6b2073aeb7ba1118183bb52286e44dd04df28.tar.gz src-aae6b2073aeb7ba1118183bb52286e44dd04df28.zip |
Merge some cherry-picked fixes originating in OpenBSD
Check whether the version field is available before looking at it.
While we're at it, use ND_TCHECK(), rather than a hand-rolled check, to
check whether we have the full fixed-length portion of the IPv4 header.
commit c67afe913011138a2504ec4d3d423b48e73b12f3
Do more length checking. From OpenBSD.
commit d7516761f9c4877bcb05bb6543be3543e165249
Notes
Notes:
svn path=/vendor/tcpdump/dist/; revision=277782
-rw-r--r-- | print-ip.c | 11 | ||||
-rw-r--r-- | print-sl.c | 2 |
2 files changed, 8 insertions, 5 deletions
diff --git a/print-ip.c b/print-ip.c index 362465e698de..830cfb324aa4 100644 --- a/print-ip.c +++ b/print-ip.c @@ -529,6 +529,7 @@ ip_print(netdissect_options *ndo, struct protoent *proto; ipds->ip = (const struct ip *)bp; + ND_TCHECK(ipds->ip->ip_vhl); if (IP_V(ipds->ip) != 4) { /* print version if != 4 */ ND_PRINT((ndo, "IP%u ", IP_V(ipds->ip))); if (IP_V(ipds->ip) == 6) @@ -537,10 +538,7 @@ ip_print(netdissect_options *ndo, else if (!ndo->ndo_eflag) ND_PRINT((ndo, "IP ")); - if ((u_char *)(ipds->ip + 1) > ndo->ndo_snapend) { - ND_PRINT((ndo, "%s", tstr)); - return; - } + ND_TCHECK(*ipds->ip); if (length < sizeof (struct ip)) { ND_PRINT((ndo, "truncated-ip %u", length)); return; @@ -669,6 +667,11 @@ ip_print(netdissect_options *ndo, ND_PRINT((ndo, " ip-proto-%d", ipds->ip->ip_p)); } } + return; + +trunc: + ND_PRINT((ndo, "%s", tstr)); + return; } void diff --git a/print-sl.c b/print-sl.c index a12a2bd6f35f..d08cd2459579 100644 --- a/print-sl.c +++ b/print-sl.c @@ -62,7 +62,7 @@ sl_if_print(netdissect_options *ndo, register u_int length = h->len; register const struct ip *ip; - if (caplen < SLIP_HDRLEN) { + if (caplen < SLIP_HDRLEN || length < SLIP_HDRLEN) { ND_PRINT((ndo, "%s", tstr)); return (caplen); } |