[Reproducible-commits] [diffoscope] 01/01: Stop crashing on misencoded readelf output

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Nov 18 13:50:11 UTC 2015


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

lunar pushed a commit to branch master
in repository diffoscope.

commit 82c6580be259f84060ae0661b2118b486c4141c7
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Nov 18 14:47:44 2015 +0100

    Stop crashing on misencoded readelf output
    
    If we can't decode the line it's likely that will not be able to filter it.
    So let's return the line unchanged to diff.
    
    Closes: #804061
---
 diffoscope/comparators/elf.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index 3e138c1..38cf665 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -40,10 +40,13 @@ class Readelf(Command):
         return []
 
     def filter(self, line):
-        # we don't care about the name of the archive
-        line = self._archive_re.sub('File: lib.a(', line.decode('utf-8'))
-        # the full path can appear in the output, we need to remove it
-        return line.replace(self.path, self._basename).encode('utf-8')
+        try:
+            # we don't care about the name of the archive
+            line = self._archive_re.sub('File: lib.a(', line.decode('utf-8'))
+            # the full path can appear in the output, we need to remove it
+            return line.replace(self.path, self._basename).encode('utf-8')
+        except UnicodeDecodeError:
+            return line
 
 class ReadelfAll(Readelf):
     def readelf_options(self):
@@ -65,10 +68,13 @@ class ObjdumpDisassemble(Command):
         return ['objdump', '--disassemble', '--full-contents', self.path]
 
     def filter(self, line):
-        # we don't care about the name of the archive
-        line = self._archive_re.sub('In archive:', line.decode('utf-8'))
-        # the full path can appear in the output, we need to remove it
-        return line.replace(self.path, self._basename).encode('utf-8')
+        try:
+            # we don't care about the name of the archive
+            line = self._archive_re.sub('In archive:', line.decode('utf-8'))
+            # the full path can appear in the output, we need to remove it
+            return line.replace(self.path, self._basename).encode('utf-8')
+        except UnicodeDecodeError:
+            return line
 
 def _compare_elf_data(path1, path2):
     differences = []

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



More information about the Reproducible-commits mailing list