Return-Path: <tiff-bounces@remotesensing.org>
Received: from inmx008.isp.belgacom.be (inmx008.isp.belgacom.be [195.238.3.88])
        by mailst034.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id i9CE1NEi015591
        for <joris.at.lebbeke@skynet.be>; Tue, 12 Oct 2004 16:01:24 +0200
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx008.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id i9CE0xhB008195
        for <joris.at.lebbeke@skynet.be>; Tue, 12 Oct 2004 16:01:00 +0200
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id DBC883A5A3F; Tue, 12 Oct 2004 10:00:29 -0400 (EDT)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from master.altlinux.ru (master.altlinux.ru [62.118.250.235])
	by xserve.flids.com (Postfix) with ESMTP id A3FFA3A5A12
	for <tiff@remotesensing.org>; Tue, 12 Oct 2004 10:00:26 -0400 (EDT)
Received: from basalt.office.altlinux.org (localhost.localdomain [127.0.0.1])
	by master.altlinux.ru (Postfix) with ESMTP id CC5FBE47F1
	for <tiff@remotesensing.org>; Tue, 12 Oct 2004 18:00:25 +0400 (MSD)
Received: by basalt.office.altlinux.org (Postfix, from userid 501)
	id 93E881522; Tue, 12 Oct 2004 18:00:25 +0400 (MSD)
Date: Tue, 12 Oct 2004 18:00:25 +0400
From: "Dmitry V. Levin" <ldv@altlinux.org>
To: tiff@remotesensing.org
Subject: Re: [Tiff] libtiff 3.7.0 beta 2
Message-ID: <20041012140025.GA568@basalt.office.altlinux.org>
References: <4168E526.1090402@coppice.org>
Mime-Version: 1.0
In-Reply-To: <4168E526.1090402@coppice.org>
X-fingerprint: 9658 398D 181B 1200 8FC5  26B8 F6F8 846B C1E2 3429
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============89824912999514295=="
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: 0e4fce4f9a2fcb6b8347473091f362db


--===============89824912999514295==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="24zk1gE8NUlDmwG9"
Content-Disposition: inline


--24zk1gE8NUlDmwG9
Content-Type: multipart/mixed; boundary="h31gzZEtNLTqOjlF"
Content-Disposition: inline


--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

On Sun, Oct 10, 2004 at 03:30:46PM +0800, Steve Underwood wrote:
> libtiff 3.7.0 beta 2 seems unable to generate TIFF files of FAX images=20
> reliably. When I try to generate a T.4 2D compressed file I get:
>=20
>    Integer overflow in TIFFVTileSize

This is known issue, attached patch should fix the problem,
please test it.


--=20
ldv

--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename="libtiff-3.7.0beta2-alt-tilesize-fix.patch"
Content-Transfer-Encoding: quoted-printable

Index: libtiff/tif_dirread.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirread.c,v
retrieving revision 1.42
diff -u -p -r1.42 tif_dirread.c
--- libtiff/tif_dirread.c	29 Sep 2004 07:42:52 -0000	1.42
+++ libtiff/tif_dirread.c	12 Oct 2004 12:41:06 -0000
@@ -644,19 +644,29 @@ TIFFReadDirectory(TIFF* tif)
 	tif->tif_curstrip =3D (tstrip_t) -1;
 	tif->tif_col =3D (uint32) -1;
 	tif->tif_curtile =3D (ttile_t) -1;
-	tif->tif_tilesize =3D TIFFTileSize(tif);
-	tif->tif_scanlinesize =3D TIFFScanlineSize(tif);
+	tif->tif_tilesize =3D (tsize_t) -1;
=20
-	if (!tif->tif_tilesize) {
-		TIFFError(module, "%s: cannot handle zero tile size",
-			  tif->tif_name);
-		return (0);
-	}
+	tif->tif_scanlinesize =3D TIFFScanlineSize(tif);
 	if (!tif->tif_scanlinesize) {
 		TIFFError(module, "%s: cannot handle zero scanline size",
 			  tif->tif_name);
 		return (0);
 	}
+
+	if (isTiled(tif)) {
+		tif->tif_tilesize =3D TIFFTileSize(tif);
+		if (!tif->tif_tilesize) {
+			TIFFError(module, "%s: cannot handle zero tile size",
+				  tif->tif_name);
+			return (0);
+		}
+	} else {
+		if (!TIFFStripSize(tif)) {
+			TIFFError(module, "%s: cannot handle zero strip size",
+				  tif->tif_name);
+			return (0);
+		}
+	}
 	return (1);
 bad:
 	if (dir)
Index: libtiff/tif_jpeg.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_jpeg.c,v
retrieving revision 1.23
diff -u -p -r1.23 tif_jpeg.c
--- libtiff/tif_jpeg.c	2 Oct 2004 13:29:41 -0000	1.23
+++ libtiff/tif_jpeg.c	12 Oct 2004 12:41:06 -0000
@@ -1396,7 +1396,7 @@ JPEGVSetField(TIFF* tif, ttag_t tag, va_
 		 * Must recalculate cached tile size
 		 * in case sampling state changed.
 		 */
-		tif->tif_tilesize =3D TIFFTileSize(tif);
+		tif->tif_tilesize =3D isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
 		return (1);			/* pseudo tag */
 	case TIFFTAG_JPEGTABLESMODE:
 		sp->jpegtablesmode =3D va_arg(ap, int);
Index: libtiff/tif_luv.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_luv.c,v
retrieving revision 1.12
diff -u -p -r1.12 tif_luv.c
--- libtiff/tif_luv.c	2 Oct 2004 13:29:41 -0000	1.12
+++ libtiff/tif_luv.c	12 Oct 2004 12:41:06 -0000
@@ -1509,7 +1509,7 @@ LogLuvVSetField(TIFF* tif, ttag_t tag, v
 		/*
 		 * Must recalculate sizes should bits/sample change.
 		 */
-		tif->tif_tilesize =3D TIFFTileSize(tif);
+		tif->tif_tilesize =3D isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
 		tif->tif_scanlinesize =3D TIFFScanlineSize(tif);
 		return (1);
 	case TIFFTAG_SGILOGENCODE:
Index: libtiff/tif_ojpeg.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_ojpeg.c,v
retrieving revision 1.13
diff -u -p -r1.13 tif_ojpeg.c
--- libtiff/tif_ojpeg.c	14 Sep 2004 06:32:19 -0000	1.13
+++ libtiff/tif_ojpeg.c	12 Oct 2004 12:41:06 -0000
@@ -2301,7 +2301,7 @@ OJPEGVSetField(register TIFF *tif,ttag_t
=20
           if ((tif->tif_flags ^ v32) & TIFF_UPSAMPLED)
             {
-              tif->tif_tilesize =3D TIFFTileSize(tif);
+              tif->tif_tilesize =3D isTiled(tif) ? TIFFTileSize(tif) : (ts=
ize_t) -1;
               tif->tif_flags |=3D TIFF_DIRTYDIRECT;
             };
           return 1;
Index: libtiff/tif_pixarlog.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_pixarlog.c,v
retrieving revision 1.7
diff -u -p -r1.7 tif_pixarlog.c
--- libtiff/tif_pixarlog.c	2 Oct 2004 13:29:41 -0000	1.7
+++ libtiff/tif_pixarlog.c	12 Oct 2004 12:41:06 -0000
@@ -1232,7 +1232,7 @@ PixarLogVSetField(TIFF* tif, ttag_t tag,
 	/*
 	 * Must recalculate sizes should bits/sample change.
 	 */
-	tif->tif_tilesize =3D TIFFTileSize(tif);
+	tif->tif_tilesize =3D isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
 	tif->tif_scanlinesize =3D TIFFScanlineSize(tif);
 	result =3D 1;		/* NB: pseudo tag */
 	break;
Index: libtiff/tif_write.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/maptools/cvsroot/libtiff/libtiff/tif_write.c,v
retrieving revision 1.15
diff -u -p -r1.15 tif_write.c
--- libtiff/tif_write.c	2 Oct 2004 13:29:41 -0000	1.15
+++ libtiff/tif_write.c	12 Oct 2004 12:41:06 -0000
@@ -528,7 +528,7 @@ TIFFWriteCheck(TIFF* tif, int tiles, con
 		    tif->tif_name, isTiled(tif) ? "tile" : "strip");
 		return (0);
 	}
-	tif->tif_tilesize =3D TIFFTileSize(tif);
+	tif->tif_tilesize =3D isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
 	tif->tif_scanlinesize =3D TIFFScanlineSize(tif);
 	tif->tif_flags |=3D TIFF_BEENWRITING;
 	return (1);

--h31gzZEtNLTqOjlF--

--24zk1gE8NUlDmwG9
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBa+N59viEa8HiNCkRAptWAJ4rwUze+YnAxQA9eizDxnZ7lseeDACghkj/
+ivpv5COMF3HymxHzrW5RDY=
=Q/v9
-----END PGP SIGNATURE-----

--24zk1gE8NUlDmwG9--

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

_______________________________________________
Tiff mailing list
Tiff@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff

--===============89824912999514295==--
