Skip to content

Commit

Permalink
Merge pull request #66 from deuill/patch-1
Browse files Browse the repository at this point in the history
Fix correctness issues for detectors
  • Loading branch information
bojand authored Jun 12, 2022
2 parents 20d2b80 + 1b5bef7 commit 3f4f379
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/matchers/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ fn msooxml(buf: &[u8]) -> Option<DocType> {
// skip to the second local file header
// since some documents include a 520-byte extra field following the file
// header, we need to scan for the next header
let mut start_offset = (u32::from_le_bytes(buf[18..22].try_into().unwrap()) + 49) as usize;
let mut start_offset = match u32::from_le_bytes(buf[18..22].try_into().unwrap()).checked_add(49)
{
Some(int) => int as usize,
None => return None,
};

let idx = search(buf, start_offset, 6000)?;

// now skip to the *third* local file header; again, we need to scan due to a
Expand Down
2 changes: 1 addition & 1 deletion src/matchers/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn is_webp(buf: &[u8]) -> bool {

/// Returns whether a buffer is Canon CR2 image data.
pub fn is_cr2(buf: &[u8]) -> bool {
buf.len() > 9
buf.len() > 10
&& ((buf[0] == 0x49 && buf[1] == 0x49 && buf[2] == 0x2A && buf[3] == 0x0)
|| (buf[0] == 0x4D && buf[1] == 0x4D && buf[2] == 0x0 && buf[3] == 0x2A))
&& buf[8] == 0x43
Expand Down

0 comments on commit 3f4f379

Please sign in to comment.