diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 9a3f8802..6ed47063 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirread.c,v 1.63 2005-11-23 22:20:56 dron Exp $ */ +/* $Id: tif_dirread.c,v 1.64 2005-12-05 15:47:36 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -576,10 +576,9 @@ TIFFReadDirectory(TIFF* tif) && td->td_stripoffset[0] != 0 && BYTECOUNTLOOKSBAD) { /* - * Plexus (and others) sometimes give a value - * of zero for a tag when they don't know what - * the correct value is! Try and handle the - * simple case of estimating the size of a one + * XXX: Plexus (and others) sometimes give a value of zero for + * a tag when they don't know what the correct value is! Try + * and handle the simple case of estimating the size of a one * strip image. */ TIFFWarning(module, @@ -588,6 +587,21 @@ TIFFReadDirectory(TIFF* tif) _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); if(EstimateStripByteCounts(tif, dir, dircount) < 0) goto bad; + } else if (td->td_nstrips > 1 + && td->td_compression == COMPRESSION_NONE + && td->td_stripoffset[0] != td->td_stripoffset[1]) { + /* + * XXX: Some vendors fill StripByteCount array with absolutely + * wrong values (it can be equal to StripOffset array, for + * example). The sample of such broken software is Pixel image + * editor by Pavel Kanzelsberger. Catch this case here. + */ + TIFFWarning(module, + "%s: Wrong \"%s\" field, ignoring and calculating from imagelength", + tif->tif_name, + _TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; } if (dir) { _TIFFfree((char *)dir);