# HG changeset patch # User Alain Mazy # Date 1772620968 -3600 # Node ID dbc3ab1ce86a5c77946186c3eb179367051c4c36 # Parent 983a74f5b8757519a7a43a3e61a037be994f58e6 fix possible overflow diff -r 983a74f5b875 -r dbc3ab1ce86a OrthancFramework/Sources/DicomFormat/DicomIntegerPixelAccessor.cpp --- a/OrthancFramework/Sources/DicomFormat/DicomIntegerPixelAccessor.cpp Tue Mar 03 16:37:24 2026 +0100 +++ b/OrthancFramework/Sources/DicomFormat/DicomIntegerPixelAccessor.cpp Wed Mar 04 11:42:48 2026 +0100 @@ -49,7 +49,7 @@ information_.GetBitsStored() >= 32) { // Not available, as the accessor internally uses int32_t values - throw OrthancException(ErrorCode_NotImplemented); + throw OrthancException(ErrorCode_NotImplemented, "No support for BitsAllocated > 32 or BitsStored >= 32"); } frame_ = 0; @@ -57,7 +57,7 @@ if (information_.GetNumberOfFrames() * frameOffset_ > size) { - throw OrthancException(ErrorCode_BadFileFormat); + throw OrthancException(ErrorCode_BadFileFormat, "Invalid size"); } if (information_.IsSigned()) diff -r 983a74f5b875 -r dbc3ab1ce86a OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp --- a/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp Tue Mar 03 16:37:24 2026 +0100 +++ b/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp Wed Mar 04 11:42:48 2026 +0100 @@ -460,6 +460,13 @@ throw OrthancException(ErrorCode_NotImplemented, std::string("Palette Color Lookup Table Descriptor invalid palette size: '") + r.c_str() + "'"); } + uint64_t expectedSize = static_cast(target->GetWidth()) * target->GetHeight(); + + if (static_cast(pixelLength) != expectedSize) + { + throw OrthancException(ErrorCode_BadFileFormat, "Invalid size"); + } + if (pixelLength != target->GetWidth() * target->GetHeight()) { DcmElement *elem; diff -r 983a74f5b875 -r dbc3ab1ce86a OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Tue Mar 03 16:37:24 2026 +0100 +++ b/OrthancServer/Sources/ServerContext.cpp Wed Mar 04 11:42:48 2026 +0100 @@ -1950,7 +1950,7 @@ } catch (OrthancException& e) { - LOG(INFO) << e.GetDetails(); + LOG(INFO) << "Failed to decode a DICOM frame: " << e.GetDetails(); } }