From owner-svn-src-stable-10@freebsd.org Thu Nov 30 00:25:27 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 455B0DEE291; Thu, 30 Nov 2017 00:25:27 +0000 (UTC) (envelope-from emaste@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 mx1.freebsd.org (Postfix) with ESMTPS id 11B026ADC2; Thu, 30 Nov 2017 00:25:26 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAU0PQ1W071485; Thu, 30 Nov 2017 00:25:26 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAU0PQU6071484; Thu, 30 Nov 2017 00:25:26 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201711300025.vAU0PQU6071484@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Thu, 30 Nov 2017 00:25:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r326380 - stable/10/contrib/binutils/bfd X-SVN-Group: stable-10 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/10/contrib/binutils/bfd X-SVN-Commit-Revision: 326380 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Nov 2017 00:25:27 -0000 Author: emaste Date: Thu Nov 30 00:25:25 2017 New Revision: 326380 URL: https://svnweb.freebsd.org/changeset/base/326380 Log: MFC r326136: bfd: avoid crash on corrupt binaries From binutils commits 5a4b0ccc20ba30caef53b01bee2c0aaa5b855339 and 7e1e19887abd24aeb15066b141cdff5541e0ec8e, made available under GPLv2 by Nick Clifton. PR: 198824 Security: CVE-2014-8501 Security: CVE-2014-8502 Modified: stable/10/contrib/binutils/bfd/peXXigen.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/binutils/bfd/peXXigen.c ============================================================================== --- stable/10/contrib/binutils/bfd/peXXigen.c Thu Nov 30 00:24:28 2017 (r326379) +++ stable/10/contrib/binutils/bfd/peXXigen.c Thu Nov 30 00:25:25 2017 (r326380) @@ -448,6 +448,17 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, { int idx; + /* PR 17512: Corrupt PE binaries can cause seg-faults. */ + if (a->NumberOfRvaAndSizes > 16) + { + (*_bfd_error_handler) + (_("%B: aout header specifies an invalid number of data-directory entries: %d"), + abfd, a->NumberOfRvaAndSizes); + /* Paranoia: If the number is corrupt, then assume that the + actual entries themselves might be corrupt as well. */ + a->NumberOfRvaAndSizes = 0; + } + for (idx = 0; idx < 16; idx++) { /* If data directory is empty, rva also should be 0. */ @@ -1426,6 +1437,15 @@ pe_print_edata (bfd * abfd, void * vfile) section->name); return TRUE; } + } + + /* PR 17512: Handle corrupt PE binaries. */ + if (datasize < 36) + { + fprintf (file, + _("\nThere is an export table in %s, but it is too small (%d)\n"), + section->name, (int) datasize); + return TRUE; } fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"),