AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2008.06.19 21:34 "[Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Steve Eddins
2008.06.19 22:04 "Re: [Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Frank Warmerdam
2008.06.20 12:02 "RE: [Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Steve Eddins
2008.06.20 13:38 "RE: [Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Bob Friesenhahn
2008.06.20 17:19 "Re: [Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Andrey Kiselev
2008.06.20 18:19 "Re: [Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Edward Lam
2008.06.22 17:15 "RE: [Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Steve Eddins

2008.06.19 22:04 "Re: [Tiff] Scalability problem in tif_dirread.c - detecting loops in IFD offsets", by Frank Warmerdam

Does anyone have any thoughts about the cycle detection code in tif_dirread.c, or about my ideas for implementing a work-around?

Steve,

There have been files in the wild with IFD loops which (if undetected) will hang TIFFOpen().

My suggestion would be to alter the libtiff code to:

  1. keep track of the IFD offset list allocation size, and only reallocate in powers of two. This means realloc() is not called for each IFD.
  2. keep the IFDs in sorted order.
  3. search for ifds in the list using a binary search (fast on ordered values).

This would mean things would scale up to large numbers of IFDs pretty gracefully (roughly O(nlogn)).

If you use the c library qsort() and bsearch() please be sensitive to portability issues.

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    | President OSGeo, http://osgeo.org