Skip to content

Commit 10ec7b2

Browse files
committed
system: Be more robust about NVRAM parsing
Fixes: #87 Signed-off-by: Hector Martin <[email protected]>
1 parent a416b49 commit 10ec7b2

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/system.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: MIT
2-
import base64, plistlib, struct, subprocess
2+
import base64, plistlib, struct, subprocess, logging
33

44
from util import *
55

@@ -85,9 +85,14 @@ def get_nvram_data(self):
8585
self.nvram = {}
8686

8787
for line in nvram_data.rstrip(b"\n").split(b"\n"):
88-
line = line.decode("ascii")
89-
k, v = line.split("\t", 1)
90-
self.nvram[k] = v
88+
try:
89+
k, v = line.split(b"\t", 1)
90+
k = k.decode("ascii")
91+
v = v.decode("utf-8")
92+
self.nvram[k] = v
93+
except:
94+
logging.warning(f"Bad nvram line: {line!r}")
95+
continue # Hopefully we don't need this value...
9196

9297
self.default_boot = None
9398
if "boot-volume" in self.nvram:

0 commit comments

Comments
 (0)