Skip to content

Commit

Permalink
Make read_version_from_raw() more robust
Browse files Browse the repository at this point in the history
Ignore the "parsed" Linux kernel version information if there are
non-ASCII at the beginning of the selected buffer.

Fixes projg2#27.

Signed-off-by: Florian Schmaus <[email protected]>
  • Loading branch information
Flowdalic committed Oct 12, 2023
1 parent 53eadd0 commit c5824c7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ecleankernel/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c5824c7

Please sign in to comment.