Mercurial > hg > orthanc
changeset 6917:310e0e445680
Also rrevent OOB when Decoding frames with plugins
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Wed, 03 Jun 2026 13:02:35 +0200 |
| parents | c149aa904805 |
| children | 78622a71d1ae |
| files | OrthancServer/Plugins/Engine/OrthancPlugins.cpp OrthancServer/Sources/ServerTranscoder.cpp |
| diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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<boost::shared_mutex> lock(pimpl_->decoderTranscoderMutex_); + if (static_cast<uint64_t>(size) > static_cast<uint64_t>(std::numeric_limits<uint32_t>::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)
--- 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<ImageAccessor> decoded; if (builtinDecoderTranscoderOrder_ == BuiltinDecoderTranscoderOrder_Before)
