diff options
author | Andrew Chant <achant@google.com> | 2019-07-08 15:53:00 -0700 |
---|---|---|
committer | Andrew Chant <achant@google.com> | 2019-07-09 17:02:48 +0000 |
commit | 5d323c17142bc9f3556a578342e06be0412901a4 (patch) | |
tree | f5b07af61a27180427635660629b6c9a6179bacd /tools/extract_kernel.py | |
parent | f5c3510081852a9781873860968535eefeda7ab3 (diff) |
Catch unicode decode errors search for kernel ver
If a kernel happens to decode to gibberish (including
non-ascii bytes), catch the decoding error when
searching for the kernel version.
Bug: 137041171
Merged-In: Ic035b3a5c8c80025cb3cede7b0fdcf8a2e5a35fd
Change-Id: Ic035b3a5c8c80025cb3cede7b0fdcf8a2e5a35fd
Diffstat (limited to 'tools/extract_kernel.py')
-rwxr-xr-x | tools/extract_kernel.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/extract_kernel.py b/tools/extract_kernel.py index 16ccb22d47..42561cf0c6 100755 --- a/tools/extract_kernel.py +++ b/tools/extract_kernel.py @@ -47,7 +47,10 @@ def get_version(input_bytes, start_idx): null_idx = input_bytes.find('\x00', start_idx) if null_idx < 0: return None - linux_banner = input_bytes[start_idx:null_idx].decode() + try: + linux_banner = input_bytes[start_idx:null_idx].decode() + except UnicodeDecodeError: + return None mo = re.match(LINUX_BANNER_REGEX, linux_banner) if mo: return mo.group(1) |