Skip to content

Commit c71dc22

Browse files
authored
Merge pull request #123 from urknall/main
fix: handle negative node read size in ubifs walk
2 parents f97f132 + 3969b7c commit c71dc22

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

ubireader/ubifs/walk.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ def _index(ubifs: Ubifs, lnum: int, offset: int, inodes: MutableMapping[int, Ino
9090
log(index , '%s file addr: %s' % (chdr, ubifs.file.last_read_addr()))
9191
verbose_display(chdr)
9292
read_size = chdr.len - UBIFS_COMMON_HDR_SZ
93+
if read_size < 0:
94+
if settings.warn_only_block_read_errors:
95+
error(index, 'Error', 'LEB: %s at %s, Node len (%s) < common header size, skipping.' % (lnum, ubifs.leb_size * lnum + offset, chdr.len))
96+
return
97+
else:
98+
error(index, 'Fatal', 'LEB: %s at %s, Node len (%s) < common header size.' % (lnum, ubifs.leb_size * lnum + offset, chdr.len))
9399
node_buf = ubifs.file.read(read_size)
94100
file_offset = ubifs.file.last_read_addr()
95101

0 commit comments

Comments
 (0)