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-1935.patch

39 lines
1.6 KiB

From 371c2d937e37b08a46eeb0628c553ce4608a45df Mon Sep 17 00:00:00 2001
From: Mathieu Malaterre <mathieu.malaterre@gmail.com>
Date: Wed, 21 Feb 2024 02:18:35 -0800
Subject: [PATCH] Remove symptoms from TALOS-2024-1935
diff --git a/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx b/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx
index fcb61e611..9457c5e9b 100644
--- a/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmImageChangeTransferSyntax.cxx
@@ -421,6 +421,7 @@ bool ImageChangeTransferSyntax::Change()
if( !b )
{
gdcmErrorMacro( "Error in getting buffer from input image." );
+ delete bv0;
return false;
}
pixeldata.SetValue( *bv0 );
diff --git a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
index 10ac23cca..430a24a87 100644
--- a/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
+++ b/Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
@@ -826,8 +826,13 @@ std::pair<char *, size_t> JPEG2000Codec::DecodeByStreamsCommon(char *dummy_buffe
// ELSCINT1_JP2vsJ2K.dcm
// -> prec = 12, bpp = 0, sgnd = 0
- //assert( wr == Dimensions[0] );
- //assert( hr == Dimensions[1] );
+ if( wr != Dimensions[0] || hr != Dimensions[1] ) {
+ gdcmErrorMacro("Invalid dimension");
+ delete[] raw;
+ opj_destroy_codec(dinfo);
+ opj_image_destroy(image);
+ return std::pair<char*,size_t>(nullptr,0);
+ }
if( comp->sgnd != PF.GetPixelRepresentation() )
{
PF.SetPixelRepresentation( (uint16_t)comp->sgnd );