Skip to content

Commit 8667d57

Browse files
authored
Merge pull request #664 from onekey-sec/fix-cpio
Handle UnicodeDecodeError on invalid CPIO entry
2 parents d302d0d + 91bf8a0 commit 8667d57

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

unblob/handlers/archive/cpio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ def parse(self): # noqa: C901
165165
"CPIO entry filename is not null-byte terminated"
166166
)
167167

168-
filename = snull(tmp_filename).decode("utf-8")
168+
try:
169+
filename = snull(tmp_filename).decode("utf-8")
170+
except UnicodeDecodeError as e:
171+
raise InvalidInputFormat from e
169172

170173
if filename == CPIO_TRAILER_NAME:
171174
current_offset += self._pad_content(c_filesize)

0 commit comments

Comments
 (0)