Skip to content

Commit 5fcab2e

Browse files
committed
fix(handler): handle false positives YAFFS sample by checking entries.
We have a YAFFS false positive sample that gets parsed but triggers a NodeIDAbsentError when calling 'self.file_entries.expand_tree(mode=Tree.DEPTH)' during extraction. This exception is raised by treelib if the tree is empty. We handle this edge case by checking if the tree is empty after the chunk identification, and raise an InvalidInputFormat if it is.
1 parent 452d926 commit 5fcab2e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

unblob/handlers/filesystem/yaffs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def init_tree(self):
299299

300300
def parse(self, store: bool = False): # noqa: C901,FBT001,FBT002
301301
self.init_tree()
302+
entries = 0
302303
for offset, page, spare in iterate_over_file(self.file, self.config):
303304
try:
304305
data_chunk = self.build_chunk(
@@ -325,8 +326,11 @@ def parse(self, store: bool = False): # noqa: C901,FBT001,FBT002
325326

326327
if store:
327328
self.insert_entry(self.build_entry(header, data_chunk))
329+
entries += 1
328330
elif store:
329331
self.data_chunks[data_chunk.object_id].append(data_chunk)
332+
if not entries:
333+
raise InvalidInputFormat("YAFFS filesystem with no entries.")
330334
self.end_offset = self.file.tell()
331335

332336
def auto_detect(self) -> YAFFSConfig:

0 commit comments

Comments
 (0)