Browse Source

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
Guillem Jover 7 years ago
parent
commit
1c1675500e
2 changed files with 8 additions and 1 deletions
  1. 2 0
      debian/changelog
  2. 6 1
      scripts/Dpkg/Shlibs/Objdump.pm

+ 2 - 0
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@gmail.com>.

+ 6 - 1
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;