Skip to content

Commit 7086bba

Browse files
committed
jffs2: ignore CRC for inaccurate node types
Ignore CRC for inaccurate node types (e.g. c001 or c002) to fix extraction of JFFS2 from two different flash dumps of two different vendors Signed-off-by: Fabrice Fontaine <[email protected]>
1 parent 0e43dde commit 7086bba

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

unblob/handlers/filesystem/jffs2.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ def guess_endian(self, file: File) -> Endian:
6666

6767
def valid_header(self, header: Instance, node_start_offset: int, eof: int) -> bool:
6868
header_crc = (binascii.crc32(header.dumps()[:-4], -1) ^ -1) & 0xFFFFFFFF
69-
70-
if header_crc != header.hdr_crc:
71-
logger.debug(
72-
"node header CRC missmatch",
73-
_verbosity=2,
74-
)
75-
return False
69+
check_crc = True
7670

7771
if header.nodetype not in JFFS2_NODETYPES:
7872
if header.nodetype | JFFS2_NODE_ACCURATE not in JFFS2_NODETYPES:
@@ -81,8 +75,15 @@ def valid_header(self, header: Instance, node_start_offset: int, eof: int) -> bo
8175
)
8276
return False
8377
logger.debug(
84-
"Not accurate JFFS2 node type", node_type=header.nodetype, _verbosity=2
78+
"Not accurate JFFS2 node type, ignore CRC",
79+
node_type=header.nodetype,
80+
_verbosity=2,
8581
)
82+
check_crc = False
83+
84+
if check_crc and header_crc != header.hdr_crc:
85+
logger.debug("node header CRC missmatch", _verbosity=2)
86+
return False
8687

8788
if node_start_offset + header.totlen > eof:
8889
logger.debug(

0 commit comments

Comments
 (0)