commit:     d21856c6b7ba9348121de36979d22d94fb0bfc16
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 29 21:55:33 2019 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Tue Jan 29 21:56:18 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d21856c6

dev-libs/elfutils: fix parsing of partial core, bug #676794

Reported-by: Demetris Nakos
Bug: https://bugs.gentoo.org/676794
Bug: https://sourceware.org/PR24103
Package-Manager: Portage-2.3.59, Repoman-2.3.12
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 ...utils-0.175.ebuild => elfutils-0.173-r1.ebuild} | 10 ++++---
 ...utils-0.175.ebuild => elfutils-0.175-r1.ebuild} |  7 +++--
 .../files/elfutils-0.173-partial-core.patch        | 34 ++++++++++++++++++++++
 3 files changed, 45 insertions(+), 6 deletions(-)

diff --git a/dev-libs/elfutils/elfutils-0.175.ebuild 
b/dev-libs/elfutils/elfutils-0.173-r1.ebuild
similarity index 92%
copy from dev-libs/elfutils/elfutils-0.175.ebuild
copy to dev-libs/elfutils/elfutils-0.173-r1.ebuild
index 39a57eb90c1..0b41180c4eb 100644
--- a/dev-libs/elfutils/elfutils-0.175.ebuild
+++ b/dev-libs/elfutils/elfutils-0.173-r1.ebuild
@@ -1,7 +1,7 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=7
+EAPI=6
 
 inherit flag-o-matic multilib-minimal
 
@@ -23,7 +23,10 @@ DEPEND="${RDEPEND}
        >=sys-devel/flex-2.5.4a
        sys-devel/m4"
 
-PATCHES=("${FILESDIR}"/${PN}-0.118-PaX-support.patch)
+PATCHES=(
+       "${FILESDIR}"/${PN}-0.118-PaX-support.patch
+       "${FILESDIR}"/${PN}-0.173-partial-core.patch
+)
 
 src_prepare() {
        default
@@ -31,7 +34,6 @@ src_prepare() {
        if ! use static-libs; then
                sed -i -e '/^lib_LIBRARIES/s:=.*:=:' -e '/^%.os/s:%.o$::' 
lib{asm,dw,elf}/Makefile.in || die
        fi
-       # https://sourceware.org/PR23914
        sed -i 's:-Werror::' */Makefile.in || die
 }
 

diff --git a/dev-libs/elfutils/elfutils-0.175.ebuild 
b/dev-libs/elfutils/elfutils-0.175-r1.ebuild
similarity index 92%
rename from dev-libs/elfutils/elfutils-0.175.ebuild
rename to dev-libs/elfutils/elfutils-0.175-r1.ebuild
index 39a57eb90c1..ad1c1988b46 100644
--- a/dev-libs/elfutils/elfutils-0.175.ebuild
+++ b/dev-libs/elfutils/elfutils-0.175-r1.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
@@ -23,7 +23,10 @@ DEPEND="${RDEPEND}
        >=sys-devel/flex-2.5.4a
        sys-devel/m4"
 
-PATCHES=("${FILESDIR}"/${PN}-0.118-PaX-support.patch)
+PATCHES=(
+       "${FILESDIR}"/${PN}-0.118-PaX-support.patch
+       "${FILESDIR}"/${PN}-0.173-partial-core.patch
+)
 
 src_prepare() {
        default

diff --git a/dev-libs/elfutils/files/elfutils-0.173-partial-core.patch 
b/dev-libs/elfutils/files/elfutils-0.173-partial-core.patch
new file mode 100644
index 00000000000..41ef14d6683
--- /dev/null
+++ b/dev-libs/elfutils/files/elfutils-0.173-partial-core.patch
@@ -0,0 +1,34 @@
+https://sourceware.org/PR24103
+https://bugs.gentoo.org/676794
+
+From da5c5336a1eaf519de246f7d9f0f5585e1d4ac59 Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <[email protected]>
+Date: Sun, 20 Jan 2019 23:05:56 +0100
+Subject: [PATCH] libdwfl: Sanity check partial core file dyn data read.
+
+When reading the dyn data from the core file check if we got everything,
+or just part of the data.
+
+https://sourceware.org/bugzilla/show_bug.cgi?id=24103
+
+Signed-off-by: Mark Wielaard <[email protected]>
+---
+ libdwfl/dwfl_segment_report_module.c | 6 ++++++
+
+--- a/libdwfl/dwfl_segment_report_module.c
++++ b/libdwfl/dwfl_segment_report_module.c
+@@ -783,6 +783,12 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const 
char *name,
+   if (dyn_filesz != 0 && dyn_filesz % dyn_entsize == 0
+       && ! read_portion (&dyn_data, &dyn_data_size, dyn_vaddr, dyn_filesz))
+     {
++      /* dyn_data_size will be zero if we got everything from the initial
++         buffer, otherwise it will be the size of the new buffer that
++         could be read.  */
++      if (dyn_data_size != 0)
++      dyn_filesz = dyn_data_size;
++
+       void *dyns = malloc (dyn_filesz);
+       Elf32_Dyn (*d32)[dyn_filesz / sizeof (Elf32_Dyn)] = dyns;
+       Elf64_Dyn (*d64)[dyn_filesz / sizeof (Elf64_Dyn)] = dyns;
+-- 
+2.20.1

Reply via email to