2005.06.17 19:49 "[Tiff] Fix for corrupted multipage TIFF", by Steve Roy

2005.06.20 15:01 "Re: [Tiff] Fix for corrupted multipage TIFF", by Frank Warmerdam

We use LibTiff to read multipage TIFFs. We found a case where the first page is invalid while the other pages are fine. Unfortunately TIFFOpen returns NULL in such a case because the code tries to load the first page and fails so it assumes everything else is bad. I found a fix that we would like to submit but not being that familiar with the code I would like to run it by you guys.

The fix is at the end of the TIFFClientOpen() function in tif_open.c. It goes like this, with my changes annotated by STEVE.

Steve,

My concern with this sort of change for handling messed up files is that it makes it very hard for applications to know if things are going OK. I would add that there are alot of ways that TIFFReadDirectory() can fail, and alot of them will not allow for graceful recover if you keep using the TIFF*.

If we were to incorporate such handling, I think it might be best to control whether it is used based on an extra open flag indicating that an error should not cause complete failure.

However, it is annoying that currently applications have no chance to recover from errors in reading the first directory that would be non-fatal in other directories.

Best regards,

---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent