diff --git a/src/jp2image.cpp b/src/jp2image.cpp index 88ab9b2d..12025f96 100644 --- a/src/jp2image.cpp +++ b/src/jp2image.cpp @@ -776,9 +776,10 @@ static void boxes_check(size_t b,size_t m) #endif box.length = (uint32_t) (io_->size() - io_->tell() + 8); } - if (box.length == 1) + if (box.length < 8) { - // FIXME. Special case. the real box size is given in another place. + // box is broken, so there is nothing we can do here + throw Error(kerCorruptedMetadata); } // Read whole box : Box header + Box data (not fixed size - can be null).