From owner-svn-src-all@freebsd.org Sat Dec 21 21:05:54 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 C9D921DCC31; Sat, 21 Dec 2019 21:05:54 +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 47gJ764y5Mz4dQs; Sat, 21 Dec 2019 21:05:54 +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 8C08F1D1A6; Sat, 21 Dec 2019 21:05:54 +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 xBLL5sA7038198; Sat, 21 Dec 2019 21:05:54 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBLL5sHC038197; Sat, 21 Dec 2019 21:05:54 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201912212105.xBLL5sHC038197@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 21 Dec 2019 21:05:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355990 - head/contrib/libpcap X-SVN-Group: head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/contrib/libpcap X-SVN-Commit-Revision: 355990 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: Sat, 21 Dec 2019 21:05:54 -0000 Author: cy Date: Sat Dec 21 21:05:53 2019 New Revision: 355990 URL: https://svnweb.freebsd.org/changeset/base/355990 Log: MFV r355890: 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 MFC after: 2 weeks Modified: head/contrib/libpcap/gencode.c head/contrib/libpcap/nametoaddr.c Directory Properties: head/contrib/libpcap/ (props changed) Modified: head/contrib/libpcap/gencode.c ============================================================================== --- head/contrib/libpcap/gencode.c Sat Dec 21 21:02:50 2019 (r355989) +++ head/contrib/libpcap/gencode.c Sat Dec 21 21:05:53 2019 (r355990) @@ -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: head/contrib/libpcap/nametoaddr.c ============================================================================== --- head/contrib/libpcap/nametoaddr.c Sat Dec 21 21:02:50 2019 (r355989) +++ head/contrib/libpcap/nametoaddr.c Sat Dec 21 21:05:53 2019 (r355990) @@ -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;