Skip to content

Commit

Permalink
fix reading images with unspecified jpgC box
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk authored and dukesook committed Nov 4, 2023
1 parent e8c158c commit c2eedac
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libheif/jpeg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "jpeg.h"
#include <string>
#include "security_limits.h"

std::string Box_jpgC::dump(Indent& indent) const
{
Expand All @@ -46,7 +47,15 @@ Error Box_jpgC::write(StreamWriter& writer) const

Error Box_jpgC::parse(BitstreamRange& range)
{
if (!has_fixed_box_size()) {
return Error{heif_error_Unsupported_feature, heif_suberror_Unspecified, "jpgC with unspecified size are not supported"};
}

size_t nBytes = range.get_remaining_bytes();
if (nBytes > MAX_MEMORY_BLOCK_SIZE) {
return Error{heif_error_Invalid_input, heif_suberror_Unspecified, "jpgC block exceeds maximum size"};
}

m_data.resize(nBytes);
range.read(m_data.data(), nBytes);
return range.get_error();
Expand Down

0 comments on commit c2eedac

Please sign in to comment.