View Revisions: Issue #3930

Summary 0003930: Crash when trying to load a DICOM ultrasound image
Revision 2018-03-22 03:11 by jcfr
Description

Slicer crashes when attempting to load an ultrasound image.

The root cause is a trivial bug in GDCMImageIO::InternalReadImageInformation(). If the image type is gdcm::MediaStorage::UltrasoundImageStorage but spacingTag(0x0028,0x0030) is not found then std::vector<double> sp remains empty but its first and second element is attempted to be accessed (spacing[0] = sp[0]), which causes an application crash.

Short-term fix: Make sure that only valid sp vector elements are accessed, for example by bounds checking:

        if (sp.size()>0)
          {
          spacing[0] = sp[0];
          }
        else
          {
          spacing[0] = 1.0;
          }
        if (sp.size()>1)
          {
          spacing[1] = sp[1];
          }
        else
          {
          spacing[1] = 1.0;
          }

Long-term fix: When image type is gdcm::MediaStorage::UltrasoundImageStorage then get spacing from PhysicalUnitsXDirection and PhysicalUnitsYDirection DICOM tags, as it is done in gdcmImageHelper.cxx GetUltraSoundSpacingValueFromSequence(). This should be fixed in GDCM or the workaround in GDCMImageIO::InternalReadImageInformation() should be made more sophisticated (e.g., by doing the same as it is done in GDCM GetUltraSoundSpacingValueFromSequence).

Revision 2018-03-22 03:10 by jcfr
Description

Slicer crashes when attempting to load an ultrasound image.

The root cause is a trivial bug in GDCMImageIO::InternalReadImageInformation(). If the image type is gdcm::MediaStorage::UltrasoundImageStorage but spacingTag(0x0028,0x0030) is not found then std::vector<double> sp remains empty but its first and second element is attempted to be accessed (spacing[0] = sp[0]), which causes an application crash.

Short-term fix: Make sure that only valid sp vector elements are accessed, for example by bounds checking:

        if (sp.size()>0)
          {
          spacing[0] = sp[0];
          }
        else
          {
          spacing[0] = 1.0;
          }
        if (sp.size()>1)
          {
          spacing[1] = sp[1];
          }
        else
          {
          spacing[1] = 1.0;
          }

Long-term fix: When image type is gdcm::MediaStorage::UltrasoundImageStorage then get spacing from PhysicalUnitsXDirection and PhysicalUnitsYDirection DICOM tags, as it is done in gdcmImageHelper.cxx GetUltraSoundSpacingValueFromSequence(). This should be fixed in GDCM or the workaround in GDCMImageIO::InternalReadImageInformation() should be made more sophisticated (e.g., by doing the same as it is done in GDCM GetUltraSoundSpacingValueFromSequence).

Revision 2014-12-29 19:33 by lassoan
Description

Slicer crashes when attempting to load an ultrasound image.

The root cause is a trivial bug in GDCMImageIO::InternalReadImageInformation(). If the image type is gdcm::MediaStorage::UltrasoundImageStorage but spacingTag(0x0028,0x0030) is not found then std::vector<double> sp remains empty but its first and second element is attempted to be accessed (spacing[0] = sp[0]), which causes an application crash.

Short-term fix: Make sure that only valid sp vector elements are accessed, for example by bounds checking:
if (sp.size()>0)
{
spacing[0] = sp[0];
}
else
{
spacing[0] = 1.0;
}
if (sp.size()>1)
{
spacing[1] = sp[1];
}
else
{
spacing[1] = 1.0;
}

Long-term fix: When image type is gdcm::MediaStorage::UltrasoundImageStorage then get spacing from PhysicalUnitsXDirection and PhysicalUnitsYDirection DICOM tags, as it is done in gdcmImageHelper.cxx GetUltraSoundSpacingValueFromSequence(). This should be fixed in GDCM or the workaround in GDCMImageIO::InternalReadImageInformation() should be made more sophisticated (e.g., by doing the same as it is done in GDCM GetUltraSoundSpacingValueFromSequence).