From af2c43fa814723a4d8f78cdfba8f94862368716f Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez-Fernandez Date: Sat, 2 Dec 2023 21:58:54 -0700 Subject: [PATCH] fix readelf output encoding handling of errors Fixes: #1147 Signed-off-by: Carlos Rodriguez-Fernandez --- rpmlint/readelfparser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rpmlint/readelfparser.py b/rpmlint/readelfparser.py index 5e6e24149..7edb46b9f 100644 --- a/rpmlint/readelfparser.py +++ b/rpmlint/readelfparser.py @@ -75,7 +75,7 @@ def __init__(self, path, extra_flags): def parse(self): r = subprocess.run(['readelf', '-W', '-S', self.path] + self.extra_flags, encoding='utf8', - capture_output=True, env=ENGLISH_ENVIROMENT) + errors='replace', capture_output=True, env=ENGLISH_ENVIROMENT) if r.returncode != 0: self.parsing_failed_reason = r.stderr return @@ -144,7 +144,7 @@ def __init__(self, path, extra_flags): def parse(self): r = subprocess.run(['readelf', '-W', '-l', self.path] + self.extra_flags, encoding='utf8', - capture_output=True, env=ENGLISH_ENVIROMENT) + errors='replace', capture_output=True, env=ENGLISH_ENVIROMENT) if r.returncode != 0: self.parsing_failed_reason = r.stderr return @@ -219,7 +219,7 @@ def __init__(self, path, extra_flags): def parse(self): r = subprocess.run(['readelf', '-W', '-d', self.path] + self.extra_flags, encoding='utf8', - capture_output=True, env=ENGLISH_ENVIROMENT) + errors='replace', capture_output=True, env=ENGLISH_ENVIROMENT) if r.returncode != 0: self.parsing_failed_reason = r.stderr return @@ -286,7 +286,7 @@ def __init__(self, path, extra_flags): def parse(self): try: r = subprocess.run(['readelf', '-Ui', '-W', '-s', self.path] + self.extra_flags, encoding='utf8', - capture_output=True, env=ENGLISH_ENVIROMENT) + errors='replace', capture_output=True, env=ENGLISH_ENVIROMENT) if r.returncode != 0: self.parsing_failed_reason = r.stderr return @@ -322,7 +322,7 @@ def __init__(self, path, extra_flags): def parse(self): r = subprocess.run(['readelf', '-p', '.comment', self.path] + self.extra_flags, encoding='utf8', - capture_output=True, env=ENGLISH_ENVIROMENT) + errors='replace', capture_output=True, env=ENGLISH_ENVIROMENT) if r.returncode != 0: self.parsing_failed_reason = r.stderr return