Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed SquashFSv2 bug, added SquashFSv2 test #806

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/structures/squashfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn parse_squashfs_header(sqsh_data: &[u8]) -> Result<SquashFSHeader, Structu
// Sanity check the version number
if squashfs_version <= MAX_SQUASHFS_VERSION && squashfs_version > 0 {
let squashfs_header_size: usize;
let squashfs_header: HashMap<String, usize>;
let mut squashfs_header: HashMap<String, usize>;

// Parse the SquashFS header, using the appropriate version header.
if squashfs_version == 4 {
Expand All @@ -123,6 +123,24 @@ pub fn parse_squashfs_header(sqsh_data: &[u8]) -> Result<SquashFSHeader, Structu
}
Ok(squash3_header) => {
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"],
);
}
}
}
}
Expand Down
Binary file added tests/inputs/squashfs_v2.bin
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/squashfs_v2.rs
Original file line number Diff line number Diff line change
@@ -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);
}
Loading