X-Account-Key: account1
X-UIDL: 6c913ae023c7cfe6aca59a66f6703060
X-Mozilla-Status: 0011
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                 
Received: from lists.maptools.org (lothlorien.howardsilvan.com [127.0.0.1])
	by mail.howardsilvan.com (Postfix) with ESMTPS id A7C736721A7
	for <faxguy@howardsilvan.com>; Fri,  3 Apr 2015 07:24:15 -0700 (PDT)
Received: from lists.maptools.org ([94.23.4.142] helo=lists.maptools.org)
	by lothlorien.howardsilvan.com with SMTP (2.3.3); 3 Apr 2015	07:24:15 -0800
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 4BCBF35C032;
	Fri,  3 Apr 2015 09:22:43 -0500 (EST)
Received: from mail-ob0-f171.google.com (mail-ob0-f171.google.com	[209.85.214.171])
	by lists.maptools.org (Postfix) with ESMTPS id 560DA35C02F
	for <tiff@lists.maptools.org>; Fri,  3 Apr 2015 09:22:34 -0500 (EST)
Received: by obbec2 with SMTP id ec2so171879111obb.3
	for <tiff@lists.maptools.org>; Fri, 03 Apr 2015 07:22:45 -0700 (PDT)
X-Received: by 10.60.133.207 with SMTP id pe15mr3206060oeb.54.1428070965598;
	Fri, 03 Apr 2015 07:22:45 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.76.127.232 with HTTP; Fri, 3 Apr 2015 07:22:25 -0700 (PDT)
In-Reply-To: <alpine.GSO.2.01.1504022052440.4186@freddy.simplesystems.org>
References:
	<CANKEqfQGsHpK2rbA2bGo3ZbE294NdJ38wSjYgTuq-vBg-PyoGg@mail.gmail.com>
	<alpine.GSO.2.01.1504022052440.4186@freddy.simplesystems.org>
From: Romain Franconville <romain.franconville@gmail.com>
Date: Fri, 3 Apr 2015 10:22:25 -0400
Message-ID: <CANKEqfS_zkuXVTPmqx87+amBpqZquRu__y907M+d=hCVNnZXWg@mail.gmail.com>
To: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
Cc: tiff@lists.maptools.org
Subject: Re: [Tiff] problem reading directories past 2GB on a 64bits system
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-Assp-ID: lothlorien.howardsilvan.com m1-71055-10437
X-Assp-Session: 7FE0CEE46E28 (mail 1)
X-Assp-Detected-RIP: 209.85.214.171
X-Assp-Source-IP: 209.85.214.171
X-Assp-Envelope-From: tiff-bounces@lists.maptools.org
X-Assp-Intended-For: faxguy@howardsilvan.com
X-Assp-Version: 2.3.3(14029) on lothlorien.howardsilvan.com
X-Assp-Server-TLS: yes
X-Assp-Delay: not delayed (whitelisted); 3 Apr 2015 07:24:15 -0800
X-Assp-Whitelisted: Yes (whitelistdb)
Return-Path: tiff-bounces@lists.maptools.org
Content-Type: multipart/mixed;
	boundary="===============1394029004=="


--===============1394029004==
Content-Type: multipart/alternative; boundary=047d7b4147e49e5e850512d2aec9


--047d7b4147e49e5e850512d2aec9
Content-Type: text/plain; charset=UTF-8

No, the directory count is well below 64k. It seems to have to do with the
2Gb limit, as I always get the error for the first frame going over it.
I'll try to check how the software producing those tiff writes them, it's
probably the source of the problem : so far I haven't found a single tiff
reading library able to open them completely.

2015-04-02 21:59 GMT-04:00 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>:

> On Thu, 2 Apr 2015, Romain Franconville wrote:
>
>  I'm using libtiff 4.0-3 on Ubuntu (64bits) 14.04.
>> I'm trying to read tiff files that are signed 16bits. Everything run
>> smoothly for files smaller than 2Gb. But I cannot
>> access directories past that limit.
>>
>> TIFFSetDirectory returns the following error in those cases :
>>
>>      TIFFFetchDirectory: Sanity check on directory count failed, zero tag
>> directories not supported.
>>      TIFFReadDirectory: Failed to read directory at offset 256.
>>
>> Opening as bigtiff doesn't make a difference (expected since it's still
>> less than 4Gb).
>>
>> Any ideas of what might be going on ?
>>
>
> Now that I am looking at the code, I see that the directory count is
> expected to fit in a 16-bit storage size.  Is it possible that you have
> more than 64k entries?
>
> This is the relevant code (after passing several other checks):
>
>                         dircount16 = (uint16)dircount64;
>                         dirsize = 20;
>                 }
>                 if (dircount16 == 0 )
>                 {
>                         TIFFErrorExt(tif->tif_clientdata, module,
>                                      "Sanity check on directory count
> failed, zero tag directories not supported");
>                         return 0;
>
>                 }
>
> Bob
> --
> Bob Friesenhahn
> bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
> GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
>

--047d7b4147e49e5e850512d2aec9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">No, the directory count is well below 64k. It seems to hav=
e to do with the 2Gb limit, as I always get the error for the first frame g=
oing over it. I&#39;ll try to check how the software producing those tiff w=
rites them, it&#39;s probably the source of the problem : so far I haven&#3=
9;t found a single tiff reading library able to open them completely.=C2=A0=
</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2015-04-02 =
21:59 GMT-04:00 Bob Friesenhahn <span dir=3D"ltr">&lt;<a href=3D"mailto:bfr=
iesen@simple.dallas.tx.us" target=3D"_blank">bfriesen@simple.dallas.tx.us</=
a>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On Thu, 2=
 Apr 2015, Romain Franconville wrote:<br>
<br>
</span><div><div class=3D"h5"><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I&#39;m using libtiff 4.0-3 on Ubuntu (64bits) 14.04.<br>
I&#39;m trying to read tiff files that are signed 16bits. Everything run sm=
oothly for files smaller than 2Gb. But I cannot<br>
access directories past that limit.<br>
<br>
TIFFSetDirectory returns the following error in those cases :<br>
<br>
=C2=A0 =C2=A0 =C2=A0TIFFFetchDirectory: Sanity check on directory count fai=
led, zero tag directories not supported.<br>
=C2=A0 =C2=A0 =C2=A0TIFFReadDirectory: Failed to read directory at offset 2=
56.<br>
<br>
Opening as bigtiff doesn&#39;t make a difference (expected since it&#39;s s=
till less than 4Gb).<br>
<br>
Any ideas of what might be going on ?=C2=A0<br>
</blockquote>
<br></div></div>
Now that I am looking at the code, I see that the directory count is expect=
ed to fit in a 16-bit storage size.=C2=A0 Is it possible that you have more=
 than 64k entries?<br>
<br>
This is the relevant code (after passing several other checks):<br>
<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 dircount16 =3D (uint16)dircount64;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 dirsize =3D 20;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (dircount16 =3D=
=3D 0 )<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 TIFFErrorExt(tif-&gt;tif_<u></u>clientdata, module,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Sanity che=
ck on directory count failed, zero tag directories not supported&quot;);<br=
>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 return 0;<div class=3D"HOEnZb"><div class=3D"h5"><br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }<br>
<br>
Bob<br>
-- <br>
Bob Friesenhahn<br>
<a href=3D"mailto:bfriesen@simple.dallas.tx.us" target=3D"_blank">bfriesen@=
simple.dallas.tx.us</a>, <a href=3D"http://www.simplesystems.org/users/bfri=
esen/" target=3D"_blank">http://www.simplesystems.org/<u></u>users/bfriesen=
/</a><br>
GraphicsMagick Maintainer,=C2=A0 =C2=A0 <a href=3D"http://www.GraphicsMagic=
k.org/" target=3D"_blank">http://www.GraphicsMagick.org/</a></div></div></b=
lockquote></div><br></div>

--047d7b4147e49e5e850512d2aec9--

--===============1394029004==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
--===============1394029004==--


