[Insight-users] strncpy problem in itkAnalyzeImageIO.cxx
Luis Ibanez
luis.ibanez at kitware.com
Sat Jun 19 10:54:21 EDT 2004
Hi Jill,
Thanks for your detailed report and
for providing the fix to this bug.
This issue was logged as Bug #941
http://www.itk.org/Bug/bug.php?op=show&bugid=941&pos=0
and the code has been fixed according
to your suggestion.
Please update your CVS checkout in order
to get the modifications.
Let us know if you find any further problems,
Thanks
Luis
-------------------------------
Jill Goldschneider 327 wrote:
> Hi,
>
> I have been having some problems writing Analyze (SPM extension I
> believe) formatted images where origin information is stored in
> the data_history's char originator[10] field. (I believe this
> field was originally intended to hold a character string.)
> If I use the ImageReadWrite example with Dimension = 3, e.g.
> ImageReadWrite image.hdr tmp.hdr
> tmp.hdr loses all of the information in the originator field,
> (and other fields as well).
>
> What I've found, is that on a sun solaris8 system, strncpy is
> actually NOT copying all 10 requested characters:
>
> // try using [ 0 128 0 128 0 64 0 0 0 0 ] in tmp.c_str()
>
> strncpy(this->m_hdr.hist.originator,temp.c_str(),10);//Note this is necessary because the array is not necessarily null terminated.
>
> // look at contents of m_hdr.hist and temp.c_str,
> // m_hdr.hist.originator is all 0!
>
> If I change this statement, and all other strncpy statements
> in the itkAnalyzeImageIO.cxx file, to use memcpy
>
> memcpy(this->m_hdr.hist.originator,temp.c_str(),10);//Note this is necessary because the array is not necessarily null terminated.
>
> then everything works much better.
>
> Would someone please consider making this change?
>
> Thanks,
>
> Jill
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
More information about the Insight-users
mailing list