2014.07.01 11:12 "[Tiff] Possible bug in tiff_dirread.c? Or user error?", by Andreas Romeyke

2014.07.01 15:56 "Re: [Tiff] Possible bug in tiff_dirread.c? Or user error?", by Joris Van Damme

Andreas,

2014-07-01 13:12 GMT+02:00 Romeyke, Andreas <Andreas.Romeyke@slub-dresden.de>:

The word 'usually' in this context is very suspicious, and it may indicate that something is going wrong in some stage prior to the one where you suspect trouble.

In my opinion, a TIFF image IFD that is organized in strips and also has either or both of TileOffsets and TileByteCounts tag, is not legit. In my experience, it is also extremely uncommon to find such a beast. GIMP actually using LibTiff (or at least I think so), this seems particularly strange.

There's also potentially something really wrong with your tool chain. The TIFF spec says there must be at most one instance of any tag in any given IFD. In other words, you can't have two 'ImageWidth' tags in the same IFD. Also, they must be ordered. You should not have an ImageLength tag before an ImageWidth tag, because ImageLength tag ID is 257 which is greater then ImageWidth tag ID 256.

Both these problems that may occur in TIFF are invisible in any layer based on LibTiff. You may not (directly) be using LibTiff to make analysis based on tag presence and such, as that would be pretty hard or impossible anyway, but I recommend double-checking that the tools you do use at that stage don't obscure these kinds problems. And there's of course other stuff that can easilly be missed with tools that implement any degree of robustness rather then being build from the ground up to allow detection of any sort of trouble. For example, pointers to subsequent IFDs may be pointing beyond EOF, and any high-level robust tool encountering this may auto-ignore that and deal with it as if it were 0 instead. Another example is, a pointer to a subsequent IFD may actually point to the IFD that contains it, or an IFD that is also present prior in the chain, or present as a child or indirect child of an IFD prior in the chain. This sort of thing is typically not protected against in recent code. Subsequently, a bug report comes in, and typically code gets protected against such mishaps by ignoring any second reference to the same IFD rather then making the exact nature of the trouble visible to calling code. Which is mostly to be regarded a good thing, of course, except in your particular and rare application. Meaning, you need to carefully investigate any tool you're using. Or, use none, build your own, that may actually be the most efficient path as the task you set out to do is not that complicated or certainly way less complicated then the tools you're using.

I realize this is not a full answer to your question - I'm not a LibTiff maintainer and my knowledge on tiffinfo and all that is very limited. But maybe it's useful, nonetheless.

Best regards,

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