From 958d9b5a8df411fa1089a02d8a8d017610670493 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 27 Apr 2016 11:38:00 +0000 Subject: [PATCH] * libtiff/tif_dirread.c: when compiled with DEFER_STRILE_LOAD, fix regression, introduced on 2014-12-23, when reading a one-strip file without a StripByteCounts tag. GDAL #6490 --- ChangeLog | 6 ++++++ libtiff/tif_dirread.c | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf395537..c9a526e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-04-27 Even Rouault + + * libtiff/tif_dirread.c: when compiled with DEFER_STRILE_LOAD, + fix regression, introduced on 2014-12-23, when reading a one-strip + file without a StripByteCounts tag. GDAL #6490 + 2016-04-07 Bob Friesenhahn * html/bugs.html: Replace Andrey Kiselev with Bob Friesenhahn for diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 80d059b8..0a7e6830 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirread.c,v 1.200 2016-01-03 10:01:25 erouault Exp $ */ +/* $Id: tif_dirread.c,v 1.201 2016-04-27 11:38:00 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -166,6 +166,8 @@ static int TIFFFetchSubjectDistance(TIFF*, TIFFDirEntry*); static void ChopUpSingleUncompressedStrip(TIFF*); static uint64 TIFFReadUInt64(const uint8 *value); +static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ); + typedef union _UInt64Aligned_t { double d; @@ -4281,7 +4283,8 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) TIFFDirectory *td = &tif->tif_dir; uint32 strip; - if( !_TIFFFillStriles( tif ) ) + /* Do not try to load stripbytecount as we will compute it */ + if( !_TIFFFillStrilesInternal( tif, 0 ) ) return -1; if (td->td_stripbytecount) @@ -5568,6 +5571,11 @@ ChopUpSingleUncompressedStrip(TIFF* tif) } int _TIFFFillStriles( TIFF *tif ) +{ + return _TIFFFillStrilesInternal( tif, 1 ); +} + +static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ) { #if defined(DEFER_STRILE_LOAD) register TIFFDirectory *td = &tif->tif_dir; @@ -5585,7 +5593,8 @@ int _TIFFFillStriles( TIFF *tif ) return_value = 0; } - if (!TIFFFetchStripThing(tif,&(td->td_stripbytecount_entry), + if (loadStripByteCount && + !TIFFFetchStripThing(tif,&(td->td_stripbytecount_entry), td->td_nstrips,&td->td_stripbytecount)) { return_value = 0; @@ -5610,6 +5619,7 @@ int _TIFFFillStriles( TIFF *tif ) return return_value; #else /* !defined(DEFER_STRILE_LOAD) */ (void) tif; + (void) loadStripByteCount; return 1; #endif }