Skip to content

Commit

Permalink
Fix divide by zero bug
Browse files Browse the repository at this point in the history
This fixes image-rs#33
  • Loading branch information
birktj committed Apr 25, 2019
1 parent f7850ad commit dbf532b
Show file tree
Hide file tree
Showing 51 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/decoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ impl<R: Read + Seek> Decoder<R> {
.get_tag_u32(ifd::Tag::RowsPerStrip)
.unwrap_or(self.height);

if rows_per_strip == 0 {
return Ok(0);
}

Ok((self.height + rows_per_strip - 1) / rows_per_strip)
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 9 additions & 0 deletions tests/fuzz_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ fn inf_loop() {
true
});
}

// https://github.com/image-rs/image-tiff/issues/33
#[test]
fn divide_by_zero() {
test_directory("./tests/fuzz_images/divide_by_zero", |file| {
decode_tiff(file).ok();
true
});
}

0 comments on commit dbf532b

Please sign in to comment.