utitilities: Add NVRAM error handling

This commit is contained in:
Mykola Grymalyuk
2022-06-30 10:40:47 -06:00
parent 5a96852ea5
commit d17372dd65
2 changed files with 7 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
- Ensure Apple Silicon-specific installers are not listed
- ie. M2 specific build (21F2092)
- Avoid adding OpenCore icon in boot picker if Windows bootloader on same partition
- Add error-handling to corrupt/non-standard NVRAM variables
## 0.4.7
- Fix crashing on defaults parsing

View File

@@ -346,7 +346,12 @@ def get_nvram(variable: str, uuid: str = None, *, decode: bool = False):
if decode:
if isinstance(value, bytes):
value = value.strip(b"\0").decode()
try:
value = value.strip(b"\0").decode()
except UnicodeDecodeError:
# Some sceanrios the firmware will throw garbage in
# ie. iMac12,2 with FireWire boot-path
value = None
elif isinstance(value, str):
value = value.strip("\0")
return value