Skip to content

Commit

Permalink
Merge pull request #44 from newpavlov/u64_pixels_limit
Browse files Browse the repository at this point in the history
Change pixels limit type from u32 to u64
  • Loading branch information
ZoeyR authored Jul 29, 2018
2 parents e7cf35e + 3199a56 commit 5c15287
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions flif/src/components/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ fn read_varint<R: Read>(reader: &mut R, delta: u32) -> Result<u32> {
}

/// Check if number of pixels uphelds provided limit
fn check_limit(width: u32, height: u32, frames: u32, limit: u32) -> Result<()> {
let pixels = frames
.checked_mul(width)
.and_then(|val| val.checked_mul(height));
fn check_limit(width: u32, height: u32, frames: u32, limit: u64) -> Result<()> {
let pixels = (frames as u64)
.checked_mul(width as u64)
.and_then(|val| val.checked_mul(height as u64));
match pixels {
Some(pix) if pix > limit => Err(Error::LimitViolation(format!(
"number of pixels exceeds limit: {}/{}",
Expand Down
2 changes: 1 addition & 1 deletion flif/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct Limits {
/// max number of metadata entries (default: 8)
pub metadata_count: u32,
/// max number of pixels: `width * height * frames` (default: 67M = 2<sup>26</sup>)
pub pixels: u32,
pub pixels: u64,
/// max number of MANIAC nodes (default: 16384 = 2<sup>14</sup>)
pub maniac_nodes: u32,
}
Expand Down

0 comments on commit 5c15287

Please sign in to comment.