dev-libs/elfutils: fix parsing of partial core, bug #676794
authorSergei Trofimovich <slyfox@gentoo.org>
Tue, 29 Jan 2019 21:55:33 +0000 (21:55 +0000)
committerSergei Trofimovich <slyfox@gentoo.org>
Tue, 29 Jan 2019 21:56:18 +0000 (21:56 +0000)
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@gentoo.org>
dev-libs/elfutils/elfutils-0.173-r1.ebuild [new file with mode: 0644]
dev-libs/elfutils/elfutils-0.175-r1.ebuild [moved from dev-libs/elfutils/elfutils-0.175.ebuild with 92% similarity]
dev-libs/elfutils/files/elfutils-0.173-partial-core.patch [new file with mode: 0644]

diff --git a/dev-libs/elfutils/elfutils-0.173-r1.ebuild b/dev-libs/elfutils/elfutils-0.173-r1.ebuild
new file mode 100644 (file)
index 0000000..0b41180
--- /dev/null
@@ -0,0 +1,69 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit flag-o-matic multilib-minimal
+
+DESCRIPTION="Libraries/utilities to handle ELF objects (drop in replacement for libelf)"
+HOMEPAGE="http://elfutils.org/"
+SRC_URI="https://sourceware.org/elfutils/ftp/${PV}/${P}.tar.bz2"
+
+LICENSE="|| ( GPL-2+ LGPL-3+ ) utils? ( GPL-3+ )"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
+IUSE="bzip2 lzma nls static-libs test +threads +utils"
+
+RDEPEND=">=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
+       bzip2? ( >=app-arch/bzip2-1.0.6-r4[${MULTILIB_USEDEP}] )
+       lzma? ( >=app-arch/xz-utils-5.0.5-r1[${MULTILIB_USEDEP}] )
+       !dev-libs/libelf"
+DEPEND="${RDEPEND}
+       nls? ( sys-devel/gettext )
+       >=sys-devel/flex-2.5.4a
+       sys-devel/m4"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-0.118-PaX-support.patch
+       "${FILESDIR}"/${PN}-0.173-partial-core.patch
+)
+
+src_prepare() {
+       default
+
+       if ! use static-libs; then
+               sed -i -e '/^lib_LIBRARIES/s:=.*:=:' -e '/^%.os/s:%.o$::' lib{asm,dw,elf}/Makefile.in || die
+       fi
+       sed -i 's:-Werror::' */Makefile.in || die
+}
+
+src_configure() {
+       use test && append-flags -g #407135
+       multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+       ECONF_SOURCE="${S}" econf \
+               $(use_enable nls) \
+               $(use_enable threads thread-safety) \
+               --program-prefix="eu-" \
+               --with-zlib \
+               $(use_with bzip2 bzlib) \
+               $(use_with lzma)
+}
+
+multilib_src_test() {
+       env     LD_LIBRARY_PATH="${BUILD_DIR}/libelf:${BUILD_DIR}/libebl:${BUILD_DIR}/libdw:${BUILD_DIR}/libasm" \
+               LC_ALL="C" \
+               emake check VERBOSE=1
+}
+
+multilib_src_install_all() {
+       einstalldocs
+       dodoc NOTES
+       # These build quick, and are needed for most tests, so don't
+       # disable their building when the USE flag is disabled.
+       if ! use utils; then
+               rm -rf "${ED}"/usr/bin || die
+       fi
+}
similarity index 92%
rename from dev-libs/elfutils/elfutils-0.175.ebuild
rename to dev-libs/elfutils/elfutils-0.175-r1.ebuild
index 39a57eb90c1287748f594a2d2abf33d5a4dceec4..ad1c1988b467976295045bc10a9389848cdb698f 100644 (file)
@@ -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 (file)
index 0000000..41ef14d
--- /dev/null
@@ -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 <mark@klomp.org>
+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 <mark@klomp.org>
+---
+ 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