From c5824c75ca12c706d334c9489220ade1ad6a09a4 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 12 Oct 2023 15:46:49 +0200 Subject: [PATCH] Make read_version_from_raw() more robust Ignore the "parsed" Linux kernel version information if there are non-ASCII at the beginning of the selected buffer. Fixes #27. Signed-off-by: Florian Schmaus --- ecleankernel/file.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ecleankernel/file.py b/ecleankernel/file.py index a158c70..472104a 100644 --- a/ecleankernel/file.py +++ b/ecleankernel/file.py @@ -213,6 +213,11 @@ def read_version_from_raw(self, return None pos += len(ver_start) sbuf = b[pos:pos + 0x100] + # Ignore the version information if there are non-ASCII + # characters at the beginning. + for byte in sbuf[:7]: + if byte < 40 or byte > 176: + return None return sbuf def read_version_from_efi(self,