ukify: catch error when loading foreign pe file
The autodetection code is supposed to throw ValueError when it
cannot figure out the version so that we fall back to the next method.
With the patch:
Kernel version not specified, starting autodetection 😖.
Real-Mode Kernel Header magic not found
+ readelf --notes vmlinuz/arm64/vmlinuz-6.0.9-300.fc37.aarch64
readelf: vmlinuz/arm64/vmlinuz-6.0.9-300.fc37.aarch64: Error: Not an ELF file - it has the wrong magic bytes at the start
Found uname version: 6.0.9-300.fc37.aarch64
This commit is contained in:
+4
-1
@@ -161,7 +161,10 @@ class Uname:
|
||||
]
|
||||
|
||||
print('+', shell_join(cmd))
|
||||
notes = subprocess.check_output(cmd, text=True)
|
||||
try:
|
||||
notes = subprocess.check_output(cmd, stderr=subprocess.PIPE, text=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
raise ValueError(e.stderr.strip()) from e
|
||||
|
||||
if not (m := re.search(cls.NOTES_PATTERN, notes, re.MULTILINE)):
|
||||
raise ValueError('Cannot find Linux version note')
|
||||
|
||||
Reference in New Issue
Block a user