Skip to content

Commit 49225f5

Browse files
authored
fix: catch UnicodeDecodeError in parsers/env.py (#5395)
Catch UnicodeDecodeError when calling read_text() to avoid a crash when parsing /usr/share/man/man7/systemd.environment-generator.7.gz Signed-off-by: Fabrice Fontaine <[email protected]>
1 parent 48059ae commit 49225f5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cve_bin_tool/parsers/env.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ def run_checker(self, filename):
9393
str: ScanInfo objects for the packages listed in the file.
9494
"""
9595
self.filename = filename
96-
contents = pathlib.Path(self.filename).read_text()
96+
try:
97+
contents = pathlib.Path(self.filename).read_text()
98+
except UnicodeDecodeError:
99+
self.logger.debug(f"{filename} is an invalid .env file")
100+
return
97101

98102
env_config = self.parse_file_contents(contents)
99103

0 commit comments

Comments
 (0)