Skip to content

Commit

Permalink
Better bounds checking in Jp2Image::printStructure
Browse files Browse the repository at this point in the history
(cherry picked from commit 0fcdde8)
  • Loading branch information
kevinbackhouse authored and hassec committed Jul 5, 2021
1 parent e486a73 commit ff00771
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/jp2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ static void boxes_check(size_t b,size_t m)

if (subBox.type == kJp2BoxTypeColorHeader) {
long pad = 3; // don't know why there are 3 padding bytes
enforce(data.size_ >= pad, kerCorruptedMetadata);
if (bPrint) {
out << " | pad:";
for (int i = 0; i < 3; i++)
Expand All @@ -546,6 +547,7 @@ static void boxes_check(size_t b,size_t m)
if (bPrint) {
out << " | iccLength:" << iccLength;
}
enforce(iccLength <= data.size_ - pad, kerCorruptedMetadata);
if (bICC) {
out.write(reinterpret_cast<const char*>(data.pData_) + pad, iccLength);
}
Expand Down

0 comments on commit ff00771

Please sign in to comment.