# HG changeset patch # User Alain Mazy # Date 1780484555 -7200 # Node ID 310e0e445680194b62cfe367c3cd53e412a48dfa # Parent c149aa904805fa3ba45d094b86c64ade4435b05f Also rrevent OOB when Decoding frames with plugins diff -r c149aa904805 -r 310e0e445680 OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Tue Jun 02 22:11:30 2026 +0200 +++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp Wed Jun 03 13:02:35 2026 +0200 @@ -6893,6 +6893,11 @@ { boost::shared_lock lock(pimpl_->decoderTranscoderMutex_); + if (static_cast(size) > static_cast(std::numeric_limits::max())) + { + throw OrthancException(ErrorCode_InternalError, "Cannot decode frame since DICOM size that is too large (size is limited to 32bits in this version of the plugin SDK)"); + } + for (PImpl::DecodeImageCallbacks::const_iterator decoder = pimpl_->decodeImageCallbacks_.begin(); decoder != pimpl_->decodeImageCallbacks_.end(); ++decoder) diff -r c149aa904805 -r 310e0e445680 OrthancServer/Sources/ServerTranscoder.cpp --- a/OrthancServer/Sources/ServerTranscoder.cpp Tue Jun 02 22:11:30 2026 +0200 +++ b/OrthancServer/Sources/ServerTranscoder.cpp Wed Jun 03 13:02:35 2026 +0200 @@ -25,6 +25,7 @@ #include "ServerTranscoder.h" #include "../../OrthancFramework/Sources/DicomParsing/DcmtkTranscoder.h" +#include "../../OrthancFramework/Sources/DicomFormat/DicomImageInformation.h" #include "../../OrthancFramework/Sources/Logging.h" #include "../../OrthancFramework/Sources/OrthancException.h" #include "../Plugins/Engine/OrthancPlugins.h" @@ -72,6 +73,14 @@ size_t size, unsigned int frameIndex) { + { // check that the target image has a valid/reasonable size before decoding to avoid possible crash or OOB during transcoding + DicomMap summary; + parsedDicom.ExtractDicomSummary(summary, 128); + + DicomImageInformation imageInfo(summary); + imageInfo.ThrowIfInvalidFrameSize(); + } + std::unique_ptr decoded; if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)