AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.09.01 20:39 "[Tiff] Stacked tiffs with colourmaps", by David Scriven
2004.09.02 01:27 "Re: [Tiff] Stacked tiffs with colourmaps", by Joris
2004.09.02 01:44 "Re: [Tiff] Stacked tiffs with colourmaps", by Chris Cox
2004.09.02 16:22 "Re: [Tiff] Stacked tiffs with colourmaps", by Ross A. Finlayson
2004.09.02 17:08 "Re: [Tiff] Stacked tiffs with colourmaps", by Bob Friesenhahn
2004.09.02 18:12 "Re: [Tiff] 16bit compressed colormaps", by Joris
2004.09.21 16:16 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Ian Ameline
2004.09.20 21:30 "[Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Ian Ameline
2004.09.21 16:01 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Joris
2004.09.27 19:14 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Ian Ameline
2004.09.27 19:34 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Joris
2004.09.24 13:02 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Joris
2004.09.24 12:36 "[Tiff] Possible (tiny) bug in LZW code", by Joris
2004.09.24 13:30 "Re: [Tiff] Possible (tiny) bug in LZW code", by Joris

2004.09.24 13:30 "Re: [Tiff] Possible (tiny) bug in LZW code", by Joris

People,

Another tif_lzw.c issue.

Inside LZWDecode, there's a lot of checking going on. Part of it is:

if (free_entp < &sp->dec_codetab[0] ||
    free_entp >= &sp->dec_codetab[CSIZE])

I don't see how this could ever happen.

free_entp is initialized as first free entry, and is, from that point on, only incremented. It cannot ever drop down to before the first entry.

And as to incrementing beyond the last entry, there's a check at one point

  if (++nbits > BITS_MAX)  /* should not happen */

Only if what is commented to not ever should be occuring, does occur, free_entp will grow beyond last entry. Next time around in this loop, the check free_entp >= &sp->dec_codetab[CSIZE] will cause an error. So how about causing an error right away, if (++nbits > BITS_MAX), and forgetting about the check in question entirely? *If* I'm not mistaking, that should boil down to the same thing, only be a little faster.

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be

Download your free TIFF tag viewer for windows here: http://www.awaresystems.be/imaging/tiff/astifftagviewer.html