diff --git a/src/structures/squashfs.rs b/src/structures/squashfs.rs index 7a16f76d4..2cffa941c 100644 --- a/src/structures/squashfs.rs +++ b/src/structures/squashfs.rs @@ -102,7 +102,7 @@ pub fn parse_squashfs_header(sqsh_data: &[u8]) -> Result 0 { let squashfs_header_size: usize; - let squashfs_header: HashMap; + let mut squashfs_header: HashMap; // Parse the SquashFS header, using the appropriate version header. if squashfs_version == 4 { @@ -123,6 +123,24 @@ pub fn parse_squashfs_header(sqsh_data: &[u8]) -> Result { squashfs_header = squash3_header.clone(); + + // Adjust the reported header values for v1 and v2 images + if squashfs_version < 3 { + squashfs_header + .insert("uid_start".to_string(), squashfs_header["uid_start_2"]); + squashfs_header + .insert("guid_start".to_string(), squashfs_header["guid_start_2"]); + squashfs_header + .insert("image_size".to_string(), squashfs_header["bytes_used_2"]); + squashfs_header.insert( + "inode_table_start".to_string(), + squashfs_header["inode_table_start_2"], + ); + squashfs_header.insert( + "directory_table_start".to_string(), + squashfs_header["directory_table_start_2"], + ); + } } } } diff --git a/tests/inputs/squashfs_v2.bin b/tests/inputs/squashfs_v2.bin new file mode 100644 index 000000000..99eeff8a0 Binary files /dev/null and b/tests/inputs/squashfs_v2.bin differ diff --git a/tests/squashfs_v2.rs b/tests/squashfs_v2.rs new file mode 100644 index 000000000..c1a8921d1 --- /dev/null +++ b/tests/squashfs_v2.rs @@ -0,0 +1,8 @@ +mod common; + +#[test] +fn integration_test() { + const SIGNATURE_TYPE: &str = "squashfs"; + const INPUT_FILE_NAME: &str = "squashfs_v2.bin"; + common::integration_test(SIGNATURE_TYPE, INPUT_FILE_NAME); +}