From owner-svn-src-all@FreeBSD.ORG Tue Jan 27 01:39:43 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 99C39B58; Tue, 27 Jan 2015 01:39:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6AA5D2EA; Tue, 27 Jan 2015 01:39:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0R1dhb0097296; Tue, 27 Jan 2015 01:39:43 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0R1dhs3097293; Tue, 27 Jan 2015 01:39:43 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201501270139.t0R1dhs3097293@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Tue, 27 Jan 2015 01:39:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r277782 - vendor/tcpdump/dist X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2015 01:39:43 -0000 Author: pfg Date: Tue Jan 27 01:39:42 2015 New Revision: 277782 URL: https://svnweb.freebsd.org/changeset/base/277782 Log: 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 Modified: vendor/tcpdump/dist/print-ip.c vendor/tcpdump/dist/print-sl.c Modified: vendor/tcpdump/dist/print-ip.c ============================================================================== --- vendor/tcpdump/dist/print-ip.c Mon Jan 26 23:45:10 2015 (r277781) +++ vendor/tcpdump/dist/print-ip.c Tue Jan 27 01:39:42 2015 (r277782) @@ -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 Modified: vendor/tcpdump/dist/print-sl.c ============================================================================== --- vendor/tcpdump/dist/print-sl.c Mon Jan 26 23:45:10 2015 (r277781) +++ vendor/tcpdump/dist/print-sl.c Tue Jan 27 01:39:42 2015 (r277782) @@ -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); }