Files
chipsec-chipsec/chipsec
Nicolas Iooss 36ca6fa5a7 Make defines.is_printable support bytes
`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>
2023-06-05 16:45:19 -07:00
..
2023-05-16 16:38:46 -07:00
2023-06-05 16:36:35 -07:00
2023-06-05 16:37:05 -07:00
2023-03-15 11:27:29 -07:00
2023-05-31 09:40:42 -07:00