Skip to content

Commit

Permalink
Ensure box clap values are sanitised
Browse files Browse the repository at this point in the history
Add two test cases to fuzz corpus to help prevent regression

Prevents possible integer overflows and floating point exceptions
  • Loading branch information
lovell committed Nov 2, 2020
1 parent f27532f commit 45503a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Binary file added fuzzing/corpus/github_367_1.heic
Binary file not shown.
Binary file added fuzzing/corpus/github_367_2.heic
Binary file not shown.
12 changes: 4 additions & 8 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2298,14 +2298,10 @@ Error Box_clap::parse(BitstreamRange& range)
{
//parse_full_box_header(range);

m_clean_aperture_width.numerator = range.read32();
m_clean_aperture_width.denominator = range.read32();
m_clean_aperture_height.numerator = range.read32();
m_clean_aperture_height.denominator = range.read32();
m_horizontal_offset.numerator = range.read32();
m_horizontal_offset.denominator = range.read32();
m_vertical_offset.numerator = range.read32();
m_vertical_offset.denominator = range.read32();
m_clean_aperture_width = Fraction(range.read32(), range.read32());
m_clean_aperture_height = Fraction(range.read32(), range.read32());
m_horizontal_offset = Fraction(range.read32(), range.read32());
m_vertical_offset = Fraction(range.read32(), range.read32());
if (!m_clean_aperture_width.is_valid() || !m_clean_aperture_height.is_valid() ||
!m_horizontal_offset.is_valid() || !m_vertical_offset.is_valid()) {
return Error(heif_error_Invalid_input,
Expand Down

0 comments on commit 45503a7

Please sign in to comment.