diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 9398035e9f..6548de8b8c 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -444,6 +444,7 @@ void Jp2Image::printStructure(std::ostream& out, PrintStructureOption option, si case kJp2BoxType::FileTypeBox: { // This box shall immediately follow the JPEG 2000 Signature box /// \todo All files shall contain one and only one File Type box. + Internal::enforce(box.length >= boxHSize, ErrorCode::kerCorruptedMetadata); Blob boxData(box.length - boxHSize); io_->readOrThrow(boxData.data(), boxData.size(), ErrorCode::kerCorruptedMetadata); if (!Internal::isValidBoxFileType(boxData))