From owner-svn-src-all@freebsd.org Thu Dec 19 00:11:19 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 831E11C9FAD; Thu, 19 Dec 2019 00:11:19 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47dXNR2qWCz3QsN; Thu, 19 Dec 2019 00:11:19 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4222A61BF; Thu, 19 Dec 2019 00:11:19 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBJ0BJ4D093551; Thu, 19 Dec 2019 00:11:19 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBJ0BISS093550; Thu, 19 Dec 2019 00:11:18 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201912190011.xBJ0BISS093550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Thu, 19 Dec 2019 00:11:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r355890 - vendor/libpcap/dist X-SVN-Group: vendor X-SVN-Commit-Author: cy X-SVN-Commit-Paths: vendor/libpcap/dist X-SVN-Commit-Revision: 355890 X-SVN-Commit-Repository: base 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.29 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: Thu, 19 Dec 2019 00:11:19 -0000 Author: cy Date: Thu Dec 19 00:11:18 2019 New Revision: 355890 URL: https://svnweb.freebsd.org/changeset/base/355890 Log: Fix libpcap issue #893: check for invalid IPv4 addresses. This fixes errors such as: tcpdump -i lagg0 net 999.999.999.999 This was originally discovered on a Red Hat 7.7 server and verified to also be a bug on FreeBSD. Obtained from: https://github.com/the-tcpdump-group/libpcap/commit/ \ 07070918d5e81a515315b395f334e52589fe0fb Fixed by: https://github.com/guyharris Modified: vendor/libpcap/dist/gencode.c vendor/libpcap/dist/nametoaddr.c Modified: vendor/libpcap/dist/gencode.c ============================================================================== --- vendor/libpcap/dist/gencode.c Wed Dec 18 23:00:56 2019 (r355889) +++ vendor/libpcap/dist/gencode.c Thu Dec 19 00:11:18 2019 (r355890) @@ -6955,11 +6955,15 @@ gen_mcode(compiler_state_t *cstate, const char *s1, co return (NULL); nlen = __pcap_atoin(s1, &n); + if (nlen < 0) + bpf_error(cstate, "invalid IPv4 address '%s'", s1); /* Promote short ipaddr */ n <<= 32 - nlen; if (s2 != NULL) { mlen = __pcap_atoin(s2, &m); + if (mlen < 0) + bpf_error(cstate, "invalid IPv4 address '%s'", s2); /* Promote short ipaddr */ m <<= 32 - mlen; if ((n & ~m) != 0) @@ -7017,8 +7021,11 @@ gen_ncode(compiler_state_t *cstate, const char *s, bpf vlen = __pcap_atodn(s, &v); if (vlen == 0) bpf_error(cstate, "malformed decnet address '%s'", s); - } else + } else { vlen = __pcap_atoin(s, &v); + if (vlen < 0) + bpf_error(cstate, "invalid IPv4 address '%s'", s); + } switch (q.addr) { Modified: vendor/libpcap/dist/nametoaddr.c ============================================================================== --- vendor/libpcap/dist/nametoaddr.c Wed Dec 18 23:00:56 2019 (r355889) +++ vendor/libpcap/dist/nametoaddr.c Thu Dec 19 00:11:18 2019 (r355890) @@ -653,8 +653,15 @@ __pcap_atoin(const char *s, bpf_u_int32 *addr) len = 0; for (;;) { n = 0; - while (*s && *s != '.') + while (*s && *s != '.') { + if (n > 25) { + /* The result will be > 255 */ + return -1; + } n = n * 10 + *s++ - '0'; + } + if (n > 255) + return -1; *addr <<= 8; *addr |= n & 0xff; len += 8;