Skip to content

Commit

Permalink
Merge pull request #790 from ReFirmLabs/carve_end
Browse files Browse the repository at this point in the history
Fixed trailing data carve bug
  • Loading branch information
devttys0 authored Dec 2, 2024
2 parents 240478a + 0388cba commit eb51707
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,14 @@ fn carve_file_map(file_data: &[u8], results: &binwalk::AnalysisResults) -> usize
last_known_offset = signature_result.offset + signature_result.size;
}

// Calculate the size of any remaining data from the end of the last signature to EOF
let remaining_data = file_data.len() - last_known_offset;

// Add any remaining unknown data to the unknown_bytes list
if remaining_data > 0 {
unknown_bytes.push((last_known_offset, remaining_data));
}

// All known signature data has been carved to disk, now carve any unknown blocks of data to disk
for (offset, size) in unknown_bytes {
if carve_file_data_to_disk(&results.file_path, file_data, "unknown", offset, size) {
Expand Down

0 comments on commit eb51707

Please sign in to comment.