From 5ad56f868bdd3b315269d7fe4fec85f3826f73a1 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Fri, 17 Oct 2025 16:53:10 +0200 Subject: [PATCH] fix: catch UnicodeDecodeError in parsers/env.py 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 --- cve_bin_tool/parsers/env.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cve_bin_tool/parsers/env.py b/cve_bin_tool/parsers/env.py index 5c776ca861..4e003c5401 100644 --- a/cve_bin_tool/parsers/env.py +++ b/cve_bin_tool/parsers/env.py @@ -93,7 +93,11 @@ def run_checker(self, filename): str: ScanInfo objects for the packages listed in the file. """ self.filename = filename - contents = pathlib.Path(self.filename).read_text() + try: + contents = pathlib.Path(self.filename).read_text() + except UnicodeDecodeError: + self.logger.debug(f"{filename} is an invalid .env file") + return env_config = self.parse_file_contents(contents)