File size-handle-recursive-elf-ar-files.patch of Package elfutils.13244

[PATCH] size: Handle recursive ELF ar files.
From: Mark Wielaard <mark at klomp dot org>
To: elfutils-devel at sourceware dot org
Cc: Mark Wielaard <mark at klomp dot org>
Date: Fri, 19 Oct 2018 01:02:26 +0200
Subject: [PATCH] size: Handle recursive ELF ar files.
Reference: bnc#1112726

eu-size didn't handle an ELF ar file that contained an ar file itself
correctly. handle_ar would recursively call itself but close the ELF
file before returning. Only close the ELF file at the top-level.

https://sourceware.org/bugzilla/show_bug.cgi?id=23787

elfutils packaging edits:
 - changelog hunk removed from original patch to avoid conflict

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog | 4 ++++
 src/size.c    | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

 2018-10-14  Mark Wielaard  <mark@klomp.org>
diff --git a/src/size.c b/src/size.c
index 5ff3f2a..f01fd88 100644
--- a/src/size.c
+++ b/src/size.c
@@ -374,8 +374,10 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname)
 	INTERNAL_ERROR (fname);
     }
 
-  if (unlikely (elf_end (elf) != 0))
-    INTERNAL_ERROR (fname);
+  /* Only close ELF handle if this was a "top level" ar file.  */
+  if (prefix == NULL)
+    if (unlikely (elf_end (elf) != 0))
+      INTERNAL_ERROR (fname);
 
   return result;
 }
-- 
1.8.3.1
openSUSE Build Service is sponsored by