You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gdcm/TALOS-2024-1944.patch

37 lines
1.4 KiB

From dda17aa8d5939e4e255ebba67aacf34b09d88692 Mon Sep 17 00:00:00 2001
From: Mathieu Malaterre <mathieu.malaterre@gmail.com>
Date: Wed, 21 Feb 2024 02:44:55 -0800
Subject: [PATCH] Remove symptoms from TALOS-2024-1944
diff --git a/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx b/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx
index 19f739399..46392461e 100644
--- a/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmRAWCodec.cxx
@@ -112,9 +112,7 @@ bool RAWCodec::DecodeBytes(const char* inBytes, size_t inBufferLength,
if(!r) return false;
std::string str = os.str();
- //std::string::size_type check = str.size();//unused
-
if( this->GetPixelFormat() == PixelFormat::UINT12 ||
this->GetPixelFormat() == PixelFormat::INT12 )
{
@@ -135,7 +133,14 @@ bool RAWCodec::DecodeBytes(const char* inBytes, size_t inBufferLength,
// DermaColorLossLess.dcm
//assert (check == inOutBufferLength || check == inOutBufferLength + 1);
// problem with: SIEMENS_GBS_III-16-ACR_NEMA_1.acr
- memcpy(outBytes, str.c_str(), inOutBufferLength);
+ size_t len = str.size();
+ if( inOutBufferLength <= len )
+ memcpy(outBytes, str.c_str(), inOutBufferLength);
+ else
+ {
+ gdcmWarningMacro( "Requesting too much data. Truncating result" );
+ memcpy(outBytes, str.c_str(), len);
+ }
}
return r;