mirror of
https://github.com/chipsec/chipsec
synced 2026-06-08 13:31:00 +00:00
36ca6fa5a7
`uefi_search.py` calls `is_printable` with bytes, in:
m = re.compile(bytes(rule['regexp'], 'utf-8')).search(efi.Image)
if m:
match_result |= MATCH_REGEXP
_str = m.group(0)
hexver = binascii.hexlify(_str)
printver = f" ('{_str}')" if defines.is_printable(_str) else ''
... because `_str` has actually type `bytes`, not `str`.
When `is_printable` is called with bytes, it always return `False`,
because in
set(seq).issubset(set(string.printable))
`set(seq)` is a set of integers and `set(string.printable)` is a set of
strings.
Fix this by always converting the parameter to string, using
`bytestostring`. This is not the most efficient way of doing this (a
more efficient would be `set(seq).issubset(set(string.printable.encode()))`
with some caching of the second set) but it is simple and makes caller
less likely to use the function in an unsupported way.
Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>