Skip to content

Commit

Permalink
Fix incorrect bounds checks for is_cr2
Browse files Browse the repository at this point in the history
This commit fixes incorrect bounds checking for the `is_cr2` detector, which would previously check for data bufffers of `len() > 9`, but would access `buf[10]`, which is invalid for buffers of `len() == 10`.
  • Loading branch information
deuill authored Jun 7, 2022
1 parent 20d2b80 commit dca6e8b
Showing 1 changed file with 1 addition and 1 deletion.
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 dca6e8b

Please sign in to comment.