# HG changeset patch # User Alain Mazy # Date 1780672267 -7200 # Node ID 9a9203c1fe4c69cc37e755defab69e61ce471bf0 # Parent ec3781d07f4872e9736bb697d3e7041c9db55251 Prevent creation of too large images at low level (fixes test_oob_monochrome_2 with GDCM in streaming branch) diff -r ec3781d07f48 -r 9a9203c1fe4c OrthancFramework/Sources/Images/ImageBuffer.cpp --- a/OrthancFramework/Sources/Images/ImageBuffer.cpp Fri Jun 05 16:53:05 2026 +0200 +++ b/OrthancFramework/Sources/Images/ImageBuffer.cpp Fri Jun 05 17:11:07 2026 +0200 @@ -26,6 +26,7 @@ #include "ImageBuffer.h" #include "../OrthancException.h" +#include "../Constants.h" #include #include @@ -49,6 +50,11 @@ const uint64_t tmpPitch = static_cast(GetBytesPerPixel()) * static_cast(width_); const uint64_t size = tmpPitch * static_cast(height_); + if (size > MAX_IMAGE_FRAME_SIZE) { + throw OrthancException(ErrorCode_BadFileFormat, std::string("Trying to create an ImageBuffer whose size (") + boost::lexical_cast(size) + " bytes) is larger than the limit (" + boost::lexical_cast(MAX_IMAGE_FRAME_SIZE) + " bytes)"); + } + + if (static_cast(static_cast(tmpPitch)) != tmpPitch || static_cast(static_cast(size)) != size) {