[dpkg] 177/200: Dpkg::Shlibs::Objdump: Fix read() error handling in get_format()

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:17:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository dpkg.

commit 1c1675500edf4285f87384af3e709c3801f87c51
Author: Guillem Jover <guillem at debian.org>
Date:   Wed Feb 8 06:08:03 2017 +0100

    Dpkg::Shlibs::Objdump: Fix read() error handling in get_format()
    
    The rest of the code handles non-binary files (ELF in this case)
    gracefully and ignores them, even though not very explicitly, as
    objdump will emit a warning that might be difficult to decrypt.
    
    We will still fail for other read failures that are not just
    short-reads, as those imply some actual problem with the passed files.
    
    Closes: #854536
---
 debian/changelog               | 2 ++
 scripts/Dpkg/Shlibs/Objdump.pm | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 9c4be3f..4bf4d0a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,8 @@ dpkg (1.18.23) UNRELEASED; urgency=medium
   * Perl modules:
     - Do not special case EM_SPARC32PLUS for NetBSD in Dpkg::Shlibs::Objdump,
       the code has been fixed in NetBSD as that situation could not happen.
+    - Fix read() error handling in Dpkg::Shlibs::Objdump::get_format() to
+      gracefully ignore non-ELF files again. Closes: #854536
   * Documentation:
     - Clarify the requirements for deb-conffile(5) pathnames. Closes: #854417
       Proposed by Dieter Adriaenssens <dieter.adriaenssens at gmail.com>.
diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm
index b5b0dc2..60c3080 100644
--- a/scripts/Dpkg/Shlibs/Objdump.pm
+++ b/scripts/Dpkg/Shlibs/Objdump.pm
@@ -180,7 +180,12 @@ sub get_format {
     my $header;
 
     open my $fh, '<', $file or syserr(g_('cannot read %s'), $file);
-    read($fh, $header, 64) == 64 or syserr(g_('cannot read %s'), $file);
+    my $rc = read $fh, $header, 64;
+    if (not defined $rc) {
+        syserr(g_('cannot read %s'), $file);
+    } elsif ($rc != 64) {
+        return;
+    }
     close $fh;
 
     my %elf;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list