From 0967cbf67b13aee818b7492533ca737f3ebd2364 Mon Sep 17 00:00:00 2001 From: Pari Malam Date: Wed, 15 Jul 2026 14:22:49 +0800 Subject: [PATCH] released --- src/formats/ubi/ubifs.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/formats/ubi/ubifs.rs b/src/formats/ubi/ubifs.rs index f6fac0b..09a6110 100644 --- a/src/formats/ubi/ubifs.rs +++ b/src/formats/ubi/ubifs.rs @@ -183,18 +183,21 @@ fn scan_nodes( } let crc = le32(image, off + 4); - let len = le32(image, off + 8) as usize; - let node_type = image[off + 12]; + // Common header: magic(0) crc(4) sqnum(8,u64) len(16,u32) node_type(20). + let len = le32(image, off + 16) as usize; + let node_type = image[off + 20]; if len < CH_SZ || off + len > n { off += 8; continue; } - // Validate CRC-32 over everything after the crc field. + // Validate CRC-32 over everything after the crc field. UBIFS uses the + // Linux crc32() (init 0xFFFFFFFF, no final XOR), which is the bitwise + // complement of the standard zlib CRC that flate2 computes. let mut c = Crc::new(); c.update(&image[off + 8..off + len]); - if c.sum() != crc { + if (c.sum() ^ 0xFFFF_FFFF) != crc { off += 8; continue; }