[Digikam-devel] [Bug 125916] Problem with opening 16bit TIFF
Marcel Wiesweg
marcel.wiesweg at gmx.de
Sat Sep 2 16:34:26 BST 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=125916
------- Additional Comments From marcel.wiesweg gmx de 2006-09-02 17:34 -------
SVN commit 580080 by mwiesweg:
- check that rows_per_strip, bits_per_sample and samples_per_pixel is not 0.
If these value are invalid, refuse to load.
- rows_per_strip of 0 results in an endless loop
- samples_per_pixel of 0 is invalid, leads to bad data
- use TiffGetFieldDefaulted instead of TiffGetField (inspired by ImageMagick)
Note: this does not fix the problem that libtiff returns invalid values,
but now digikam notices the fact.
CCBUG: 125916
M +20 -7 tiffloader.cpp
--- trunk/extragear/graphics/digikam/libs/dimg/loaders/tiffloader.cpp #580079:580080
@ -124,19 +124,32 @
tsize_t strip_size;
tstrip_t num_of_strips;
- TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
- TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_IMAGEWIDTH, &w);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_IMAGELENGTH, &h);
- TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bits_per_sample);
- TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
- TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rows_per_strip);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bits_per_sample);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samples_per_pixel);
+ TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rows_per_strip);
- if (TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rows_per_strip) == 0)
+ if (TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rows_per_strip) == 0 || rows_per_strip == 0)
{
- kdDebug() << k_funcinfo << "Can't handle non-stripped images." << endl;
+ kdWarning() << "TIFF loader: Cannot handle non-stripped images. Loading file " << filePath << endl;
TIFFClose(tif);
return false;
}
+
+ if (bits_per_sample == 0 ||
+ samples_per_pixel == 0 ||
+ rows_per_strip == 0)
+ {
+ kdWarning() << "TIFF loader: Encountered invalid value 0 in image."
+ << " bits_per_sample " << bits_per_sample
+ << " samples_per_pixel " << samples_per_pixel
+ << " rows_per_strip " << rows_per_strip
+ << " Loading file " << filePath << endl;
+ TIFFClose(tif);
+ return false;
+ }
TIFFGetFieldDefaulted(tif, TIFFTAG_PHOTOMETRIC, &photometric);
/*
More information about the Digikam-devel
mailing list