[Dcmlib] some bugs with "MONOCHROM1 " and "MONOCHROM2 "

derong denis_hudr at sina.com
Thu Nov 11 23:09:53 CET 2004


Hi, Mathieu
 
It seems i have found a serious bug after i do some testing.
 
In the file gdcmHeader.cxx, there are some codes as follows:
 
 // beware of trailing space at end of string      
   // DICOM tags are never of odd length
   if ( strPhotometricInterpretation == GDCM_UNFOUND   || 
        strPhotometricInterpretation == "MONOCHROME1 " || 
        strPhotometricInterpretation == "MONOCHROME2 " )
   {
      return 1;
   }
 
there is a space added to the tail of "MONOCHROM1 " and "MONOCHROM2 ".
I have read some file that there is no space added the tail, that will cause
crash when we set component number to 3.
 
I think that component number is important to read DICOM file, we can not
just set it to 3 if we can not identify it.(it is dangerous to do memcpy)
 
And we can compare the string value by following.
 
std:string strPINoSpace(strPhotometricInterpretation, 0,
strPhotometricInterpretation.find_first(' '));
 
if ( strPhotometricInterpretation == GDCM_UNFOUND   || 
     strPINoSpace  == "MONOCHROME1" || 
     strPINoSpace == "MONOCHROME2" )
   {
      return 1;
   }
 
I think that is more robust. maybe that dicom file violates the DICOM
conformance."DICOM tags are never of odd length".
 
How do you think about it?
 
thx,
 
Dennis
   
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.creatis.insa-lyon.fr/pipermail/dcmlib/attachments/20041111/273b2019/attachment.html>


More information about the Dcmlib mailing list