From 6c67067c05036ea098b8de9f6b7860b68bce7568 Mon Sep 17 00:00:00 2001 From: "DESKTOP-AU32L56\\Purushothaman" Date: Fri, 17 Oct 2025 13:28:34 +0530 Subject: [PATCH] code crashes when DICOM with 12 bits allocated is processed --- .../gdcm/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx b/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx index 18208127cda..187681c38f4 100644 --- a/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx +++ b/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx @@ -117,6 +117,12 @@ bool RAWCodec::DecodeBytes(const char* inBytes, size_t inBufferLength, this->GetPixelFormat() == PixelFormat::INT12 ) { size_t len = str.size() * 16 / 12; + if (inOutBufferLength != len) + { + gdcmDebugMacro("inOutBufferLength = " << inOutBufferLength + << ", inBufferLength = " << inBufferLength << ", len = " << len) + return false; + } char * copy = new char[len]; bool b = Unpacker12Bits::Unpack(copy, str.data(), str.size() ); if (!b)