Skip to content

Commit 0fd682d

Browse files
author
pierre
committed
Add a frame size check to ensure that the provided data corresponds to the buffer size
1 parent fc9ac24 commit 0fd682d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Source/MediaStorageAndFileFormat/gdcmJPEGBITSCodec.hxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,13 @@ bool JPEGBITSCodec::InternalCode(const char* input, unsigned long len, std::ostr
11681168
int image_height = dims[1]; /* Number of rows in image */
11691169
int image_width = dims[0]; /* Number of columns in image */
11701170

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

0 commit comments

Comments
 (0)