Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/MediaStorageAndFileFormat/gdcmJPEG2000Codec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,8 @@ bool JPEG2000Codec::GetHeaderInfo(const char * dummy_buffer, size_t buf_size, Tr
opj_stream_t *cio = nullptr;
opj_image_t *image = nullptr;
const unsigned char *src = (const unsigned char*)dummy_buffer;
if(!src)
return false ;
size_t file_length = buf_size;

/* set decoding parameters to default values */
Expand Down
7 changes: 7 additions & 0 deletions Source/MediaStorageAndFileFormat/gdcmJPEGBITSCodec.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,13 @@ bool JPEGBITSCodec::InternalCode(const char* input, unsigned long len, std::ostr
int image_height = dims[1]; /* Number of rows in image */
int image_width = dims[0]; /* Number of columns in image */

// Check if provided buffer correspond to image parameters for current frame
size_t expected_frame_size = (size_t)image_width * image_height *
this->GetPixelFormat().GetPixelSize();
if (len != expected_frame_size) {
gdcmErrorMacro("Frame size don't match");
return false;
}
/* This struct contains the JPEG compression parameters and pointers to
* working space (which is allocated as needed by the JPEG library).
* It is possible to have several such structures, representing multiple
Expand Down