InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

Crash in gdcm::Rescaler::InverseRescale when using RGB DICOM file

Open
#1,808 10 comments 0 reactions 0 assignees View on GitHub
status:Use_Milestone_Backlog
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

I think there is a bug at this line:

https://github.com/InsightSoftwareConsortium/ITK/blob/ee2ab9c973e66616cc2132f9a96fcf7763a6b94d/Modules/IO/GDCM/src/itkGDCMImageIO.cxx#L1202

len does not take into account RGB images so it is 1/3 of the the correct size for those. GDCM documentation for

gdcm::Bitmap::GetBufferLength() states "Return the length of the image after decompression WARNING for palette color: It will NOT take into account the Palette Color thus you need to multiply this length by 3 if computing the size of equivalent RGB image"

In the Image I tested (can't share patient image) len is 1697400 and numberOfBytes is 5092200 and inside `gdcm::Rescaler::InverseRescale` the memcpy(out,in,n); tries to copy the 5092200 bytes into the buffer that was allocated as 1697400 bytes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.