From 7d9fbf6d9d647928809975e40edb71ff96c7e3c9 Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Thu, 8 Dec 2011 05:48:39 +0000 Subject: [PATCH] fix crash with invalid files, strip chopping and deferred strile loading (gdal #4372) --- ChangeLog | 3 +++ libtiff/tif_dirread.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index d0bccd97..44b86f57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-12-07 Frank Warmerdam + * libtiff/tif_dirread.c: fixes to deal with invalid files where + _TIFFFillStriles() fails, and we try to chop up strips (gdal #4372) + * libtiff/tif_dirread.c: fix error reporting when there is no tag information struct and name (gdal #4373) diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 5e15fe0a..81d0dd36 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirread.c,v 1.170 2011-12-08 05:43:26 fwarmerdam Exp $ */ +/* $Id: tif_dirread.c,v 1.171 2011-12-08 05:48:39 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -4026,7 +4026,11 @@ TIFFReadDirectory(TIFF* tif) (tif->tif_dir.td_nstrips==1)&& (tif->tif_dir.td_compression==COMPRESSION_NONE)&& ((tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED))==TIFF_STRIPCHOP)) + { + if ( !_TIFFFillStriles(tif) || !tif->tif_dir.td_stripbytecount ) + return 0; ChopUpSingleUncompressedStrip(tif); + } /* * Clear the dirty directory flag. @@ -5459,8 +5463,6 @@ ChopUpSingleUncompressedStrip(TIFF* tif) uint64* newcounts; uint64* newoffsets; - _TIFFFillStriles(tif); - bytecount = td->td_stripbytecount[0]; offset = td->td_stripoffset[0]; assert(td->td_planarconfig == PLANARCONFIG_CONTIG);