Skip to content

Commit

Permalink
remove nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19 committed Jun 11, 2023
1 parent effadc4 commit f24856c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/matchers/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,16 +218,17 @@ pub fn is_zst(buf: &[u8]) -> bool {
}

let magic = u32::from_le_bytes(buf[0..4].try_into().unwrap()) as usize;
if magic & ZSTD_SKIP_MASK == ZSTD_SKIP_START {
let data_len = u32::from_le_bytes(buf[4..8].try_into().unwrap()) as usize;
if buf.len() < 8 + data_len {
return false;
}
let next_frame = &buf[8 + data_len..];
return is_zst(next_frame);
if magic & ZSTD_SKIP_MASK != ZSTD_SKIP_START {
return false;
}

let data_len = u32::from_le_bytes(buf[4..8].try_into().unwrap()) as usize;
if buf.len() < 8 + data_len {
return false;
}

false
let next_frame = &buf[8 + data_len..];
is_zst(next_frame)
}

/// Returns whether a buffer is a MSI Windows Installer archive.
Expand Down

0 comments on commit f24856c

Please sign in to comment.