1999-07-27 17:50:26 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1988-1997 Sam Leffler
|
|
|
|
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and
|
|
|
|
* its documentation for any purpose is hereby granted without fee, provided
|
|
|
|
* that (i) the above copyright notices and this permission notice appear in
|
|
|
|
* all copies of the software and related documentation, and (ii) the names of
|
|
|
|
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
|
|
|
* publicity relating to the software without the specific, prior written
|
|
|
|
* permission of Sam Leffler and Silicon Graphics.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
|
|
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
|
|
|
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TIFF Library.
|
|
|
|
*
|
|
|
|
* Directory Tag Get & Set Routines.
|
|
|
|
* (and also some miscellaneous stuff)
|
|
|
|
*/
|
|
|
|
#include "tiffiop.h"
|
2019-12-19 16:04:44 -05:00
|
|
|
#include <float.h> /*--: for Rational2Double */
|
1999-07-27 17:50:26 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These are used in the backwards compatibility code...
|
|
|
|
*/
|
|
|
|
#define DATATYPE_VOID 0 /* !untyped data */
|
|
|
|
#define DATATYPE_INT 1 /* !signed integer data */
|
|
|
|
#define DATATYPE_UINT 2 /* !unsigned integer data */
|
|
|
|
#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
|
|
|
|
|
2004-09-25 07:05:58 -04:00
|
|
|
static void
|
|
|
|
setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2016-09-04 17:32:55 -04:00
|
|
|
if (*vpp) {
|
|
|
|
_TIFFfree(*vpp);
|
|
|
|
*vpp = 0;
|
|
|
|
}
|
2004-09-25 07:05:58 -04:00
|
|
|
if (vp) {
|
2019-08-16 13:47:42 -04:00
|
|
|
tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL);
|
2019-08-16 13:59:18 -04:00
|
|
|
if (bytes)
|
2004-09-25 07:05:58 -04:00
|
|
|
*vpp = (void*) _TIFFmalloc(bytes);
|
|
|
|
if (*vpp)
|
|
|
|
_TIFFmemcpy(*vpp, vp, bytes);
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
2005-04-08 06:15:37 -04:00
|
|
|
void _TIFFsetByteArray(void** vpp, void* vp, uint32 n)
|
2004-09-25 07:05:58 -04:00
|
|
|
{ setByteArray(vpp, vp, n, 1); }
|
1999-07-27 17:50:26 -04:00
|
|
|
void _TIFFsetString(char** cpp, char* cp)
|
2004-09-25 07:05:58 -04:00
|
|
|
{ setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); }
|
2015-10-28 15:10:20 -04:00
|
|
|
static void _TIFFsetNString(char** cpp, char* cp, uint32 n)
|
2004-09-25 07:05:58 -04:00
|
|
|
{ setByteArray((void**) cpp, (void*) cp, n, 1); }
|
2005-04-08 06:15:37 -04:00
|
|
|
void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n)
|
2004-09-25 07:05:58 -04:00
|
|
|
{ setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); }
|
2005-04-08 06:15:37 -04:00
|
|
|
void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n)
|
2004-09-25 07:05:58 -04:00
|
|
|
{ setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); }
|
2015-10-28 15:10:20 -04:00
|
|
|
static void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n)
|
2007-06-12 09:07:32 -04:00
|
|
|
{ setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); }
|
2005-04-08 06:15:37 -04:00
|
|
|
void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n)
|
2004-09-25 07:05:58 -04:00
|
|
|
{ setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); }
|
2005-04-08 06:15:37 -04:00
|
|
|
void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n)
|
2004-09-25 07:05:58 -04:00
|
|
|
{ setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); }
|
1999-07-27 17:50:26 -04:00
|
|
|
|
2011-01-24 16:06:31 -05:00
|
|
|
static void
|
|
|
|
setDoubleArrayOneValue(double** vpp, double value, size_t nmemb)
|
|
|
|
{
|
|
|
|
if (*vpp)
|
|
|
|
_TIFFfree(*vpp);
|
|
|
|
*vpp = _TIFFmalloc(nmemb*sizeof(double));
|
|
|
|
if (*vpp)
|
|
|
|
{
|
|
|
|
while (nmemb--)
|
|
|
|
((double*)*vpp)[nmemb] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
/*
|
|
|
|
* Install extra samples information.
|
|
|
|
*/
|
|
|
|
static int
|
2019-02-02 09:30:14 -05:00
|
|
|
setExtraSamples(TIFF* tif, va_list ap, uint32* v)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2007-02-22 09:07:16 -05:00
|
|
|
/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
|
|
|
|
#define EXTRASAMPLE_COREL_UNASSALPHA 999
|
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
uint16* va;
|
2005-06-05 12:33:09 -04:00
|
|
|
uint32 i;
|
2019-02-02 09:30:14 -05:00
|
|
|
TIFFDirectory* td = &tif->tif_dir;
|
|
|
|
static const char module[] = "setExtraSamples";
|
1999-07-27 17:50:26 -04:00
|
|
|
|
2007-06-27 08:28:15 -04:00
|
|
|
*v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
if ((uint16) *v > td->td_samplesperpixel)
|
2007-02-22 09:07:16 -05:00
|
|
|
return 0;
|
1999-07-27 17:50:26 -04:00
|
|
|
va = va_arg(ap, uint16*);
|
|
|
|
if (*v > 0 && va == NULL) /* typically missing param */
|
2007-02-22 09:07:16 -05:00
|
|
|
return 0;
|
|
|
|
for (i = 0; i < *v; i++) {
|
|
|
|
if (va[i] > EXTRASAMPLE_UNASSALPHA) {
|
|
|
|
/*
|
|
|
|
* XXX: Corel Draw is known to produce incorrect
|
|
|
|
* ExtraSamples tags which must be patched here if we
|
|
|
|
* want to be able to open some of the damaged TIFF
|
|
|
|
* files:
|
|
|
|
*/
|
|
|
|
if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA)
|
|
|
|
va[i] = EXTRASAMPLE_UNASSALPHA;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2019-02-02 09:30:14 -05:00
|
|
|
|
|
|
|
if ( td->td_transferfunction[0] != NULL && (td->td_samplesperpixel - *v > 1) &&
|
|
|
|
!(td->td_samplesperpixel - td->td_extrasamples > 1))
|
|
|
|
{
|
|
|
|
TIFFWarningExt(tif->tif_clientdata,module,
|
|
|
|
"ExtraSamples tag value is changing, "
|
|
|
|
"but TransferFunction was read with a different value. Cancelling it");
|
|
|
|
TIFFClrFieldBit(tif,FIELD_TRANSFERFUNCTION);
|
|
|
|
_TIFFfree(td->td_transferfunction[0]);
|
|
|
|
td->td_transferfunction[0] = NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
td->td_extrasamples = (uint16) *v;
|
|
|
|
_TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples);
|
2007-02-22 09:07:16 -05:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
#undef EXTRASAMPLE_COREL_UNASSALPHA
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
|
2012-05-23 21:03:37 -04:00
|
|
|
/*
|
|
|
|
* Confirm we have "samplesperpixel" ink names separated by \0. Returns
|
|
|
|
* zero if the ink names are not as expected.
|
|
|
|
*/
|
2005-04-08 06:15:37 -04:00
|
|
|
static uint32
|
|
|
|
checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
|
|
|
TIFFDirectory* td = &tif->tif_dir;
|
2005-04-08 06:15:37 -04:00
|
|
|
uint16 i = td->td_samplesperpixel;
|
1999-07-27 17:50:26 -04:00
|
|
|
|
|
|
|
if (slen > 0) {
|
|
|
|
const char* ep = s+slen;
|
|
|
|
const char* cp = s;
|
|
|
|
for (; i > 0; i--) {
|
2012-05-23 21:03:37 -04:00
|
|
|
for (; cp < ep && *cp != '\0'; cp++) {}
|
|
|
|
if (cp >= ep)
|
|
|
|
goto bad;
|
1999-07-27 17:50:26 -04:00
|
|
|
cp++; /* skip \0 */
|
|
|
|
}
|
2007-06-26 08:31:25 -04:00
|
|
|
return ((uint32)(cp-s));
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
bad:
|
2005-12-21 07:23:13 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
|
1999-07-27 17:50:26 -04:00
|
|
|
"%s: Invalid InkNames value; expecting %d names, found %d",
|
|
|
|
tif->tif_name,
|
|
|
|
td->td_samplesperpixel,
|
|
|
|
td->td_samplesperpixel-i);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-04-04 00:16:07 -04:00
|
|
|
_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2003-06-30 14:25:50 -04:00
|
|
|
static const char module[] = "_TIFFVSetField";
|
2006-10-12 12:50:55 -04:00
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
TIFFDirectory* td = &tif->tif_dir;
|
|
|
|
int status = 1;
|
2005-04-08 06:15:37 -04:00
|
|
|
uint32 v32, i, v;
|
2014-12-21 10:15:31 -05:00
|
|
|
double dblval;
|
1999-07-27 17:50:26 -04:00
|
|
|
char* s;
|
2012-05-30 00:58:13 -04:00
|
|
|
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
|
|
|
|
uint32 standard_tag = tag;
|
2014-11-20 11:47:21 -05:00
|
|
|
if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */
|
|
|
|
return 0;
|
2012-05-30 00:58:13 -04:00
|
|
|
/*
|
|
|
|
* We want to force the custom code to be used for custom
|
|
|
|
* fields even if the tag happens to match a well known
|
|
|
|
* one - important for reinterpreted handling of standard
|
2016-01-23 16:20:34 -05:00
|
|
|
* tag values in custom directories (i.e. EXIF)
|
2012-05-30 00:58:13 -04:00
|
|
|
*/
|
|
|
|
if (fip->field_bit == FIELD_CUSTOM) {
|
|
|
|
standard_tag = 0;
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
|
2012-05-30 00:58:13 -04:00
|
|
|
switch (standard_tag) {
|
1999-07-27 17:50:26 -04:00
|
|
|
case TIFFTAG_SUBFILETYPE:
|
2007-04-18 20:51:47 -04:00
|
|
|
td->td_subfiletype = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_IMAGEWIDTH:
|
2007-04-18 20:51:47 -04:00
|
|
|
td->td_imagewidth = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_IMAGELENGTH:
|
2007-04-18 20:51:47 -04:00
|
|
|
td->td_imagelength = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_BITSPERSAMPLE:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_bitspersample = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
/*
|
Make DocumentName, Artist, HostComputer, ImageDescription, Make, Model,
Copyright, DateTime, PageName, TextureFormat, TextureWrapModes and
TargetPrinter tags custom.
2005-06-01 06:17:21 -04:00
|
|
|
* If the data require post-decoding processing to byte-swap
|
|
|
|
* samples, set it up here. Note that since tags are required
|
|
|
|
* to be ordered, compression code can override this behaviour
|
|
|
|
* in the setup method if it wants to roll the post decoding
|
|
|
|
* work in with its normal work.
|
1999-07-27 17:50:26 -04:00
|
|
|
*/
|
|
|
|
if (tif->tif_flags & TIFF_SWAB) {
|
2010-07-02 05:48:25 -04:00
|
|
|
if (td->td_bitspersample == 8)
|
|
|
|
tif->tif_postdecode = _TIFFNoPostDecode;
|
|
|
|
else if (td->td_bitspersample == 16)
|
1999-07-27 17:50:26 -04:00
|
|
|
tif->tif_postdecode = _TIFFSwab16BitData;
|
2005-04-13 10:06:21 -04:00
|
|
|
else if (td->td_bitspersample == 24)
|
2007-04-18 20:51:47 -04:00
|
|
|
tif->tif_postdecode = _TIFFSwab24BitData;
|
1999-07-27 17:50:26 -04:00
|
|
|
else if (td->td_bitspersample == 32)
|
|
|
|
tif->tif_postdecode = _TIFFSwab32BitData;
|
|
|
|
else if (td->td_bitspersample == 64)
|
|
|
|
tif->tif_postdecode = _TIFFSwab64BitData;
|
2005-07-30 23:33:11 -04:00
|
|
|
else if (td->td_bitspersample == 128) /* two 64's */
|
|
|
|
tif->tif_postdecode = _TIFFSwab64BitData;
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFFTAG_COMPRESSION:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
/*
|
Make DocumentName, Artist, HostComputer, ImageDescription, Make, Model,
Copyright, DateTime, PageName, TextureFormat, TextureWrapModes and
TargetPrinter tags custom.
2005-06-01 06:17:21 -04:00
|
|
|
* If we're changing the compression scheme, the notify the
|
|
|
|
* previous module so that it can cleanup any state it's
|
|
|
|
* setup.
|
1999-07-27 17:50:26 -04:00
|
|
|
*/
|
|
|
|
if (TIFFFieldSet(tif, FIELD_COMPRESSION)) {
|
2007-04-04 00:16:07 -04:00
|
|
|
if ((uint32)td->td_compression == v)
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
(*tif->tif_cleanup)(tif);
|
|
|
|
tif->tif_flags &= ~TIFF_CODERSETUP;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Setup new compression routine state.
|
|
|
|
*/
|
1999-09-08 15:07:02 -04:00
|
|
|
if( (status = TIFFSetCompressionScheme(tif, v)) != 0 )
|
2007-04-18 20:51:47 -04:00
|
|
|
td->td_compression = (uint16) v;
|
|
|
|
else
|
|
|
|
status = 0;
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_PHOTOMETRIC:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_photometric = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_THRESHHOLDING:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_threshholding = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_FILLORDER:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
|
|
|
|
goto badvalue;
|
|
|
|
td->td_fillorder = (uint16) v;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_ORIENTATION:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
2006-10-12 12:50:55 -04:00
|
|
|
if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
|
|
|
|
goto badvalue;
|
|
|
|
else
|
1999-07-27 17:50:26 -04:00
|
|
|
td->td_orientation = (uint16) v;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_SAMPLESPERPIXEL:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v == 0)
|
|
|
|
goto badvalue;
|
2016-10-25 17:35:15 -04:00
|
|
|
if( v != td->td_samplesperpixel )
|
|
|
|
{
|
|
|
|
/* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */
|
|
|
|
if( td->td_sminsamplevalue != NULL )
|
|
|
|
{
|
|
|
|
TIFFWarningExt(tif->tif_clientdata,module,
|
|
|
|
"SamplesPerPixel tag value is changing, "
|
|
|
|
"but SMinSampleValue tag was read with a different value. Cancelling it");
|
|
|
|
TIFFClrFieldBit(tif,FIELD_SMINSAMPLEVALUE);
|
|
|
|
_TIFFfree(td->td_sminsamplevalue);
|
|
|
|
td->td_sminsamplevalue = NULL;
|
|
|
|
}
|
|
|
|
if( td->td_smaxsamplevalue != NULL )
|
|
|
|
{
|
|
|
|
TIFFWarningExt(tif->tif_clientdata,module,
|
|
|
|
"SamplesPerPixel tag value is changing, "
|
|
|
|
"but SMaxSampleValue tag was read with a different value. Cancelling it");
|
|
|
|
TIFFClrFieldBit(tif,FIELD_SMAXSAMPLEVALUE);
|
|
|
|
_TIFFfree(td->td_smaxsamplevalue);
|
|
|
|
td->td_smaxsamplevalue = NULL;
|
|
|
|
}
|
2018-11-21 12:50:34 -05:00
|
|
|
/* Test if 3 transfer functions instead of just one are now needed
|
|
|
|
See http://bugzilla.maptools.org/show_bug.cgi?id=2820 */
|
|
|
|
if( td->td_transferfunction[0] != NULL && (v - td->td_extrasamples > 1) &&
|
|
|
|
!(td->td_samplesperpixel - td->td_extrasamples > 1))
|
|
|
|
{
|
|
|
|
TIFFWarningExt(tif->tif_clientdata,module,
|
|
|
|
"SamplesPerPixel tag value is changing, "
|
|
|
|
"but TransferFunction was read with a different value. Cancelling it");
|
|
|
|
TIFFClrFieldBit(tif,FIELD_TRANSFERFUNCTION);
|
|
|
|
_TIFFfree(td->td_transferfunction[0]);
|
|
|
|
td->td_transferfunction[0] = NULL;
|
|
|
|
}
|
2016-10-25 17:35:15 -04:00
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
td->td_samplesperpixel = (uint16) v;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_ROWSPERSTRIP:
|
2007-04-18 20:51:47 -04:00
|
|
|
v32 = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v32 == 0)
|
|
|
|
goto badvalue32;
|
|
|
|
td->td_rowsperstrip = v32;
|
|
|
|
if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) {
|
|
|
|
td->td_tilelength = v32;
|
|
|
|
td->td_tilewidth = td->td_imagewidth;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFFTAG_MINSAMPLEVALUE:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_minsamplevalue = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_MAXSAMPLEVALUE:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_maxsamplevalue = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_SMINSAMPLEVALUE:
|
2011-01-24 16:06:31 -05:00
|
|
|
if (tif->tif_flags & TIFF_PERSAMPLE)
|
|
|
|
_TIFFsetDoubleArray(&td->td_sminsamplevalue, va_arg(ap, double*), td->td_samplesperpixel);
|
|
|
|
else
|
|
|
|
setDoubleArrayOneValue(&td->td_sminsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_SMAXSAMPLEVALUE:
|
2011-01-24 16:06:31 -05:00
|
|
|
if (tif->tif_flags & TIFF_PERSAMPLE)
|
|
|
|
_TIFFsetDoubleArray(&td->td_smaxsamplevalue, va_arg(ap, double*), td->td_samplesperpixel);
|
|
|
|
else
|
|
|
|
setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_XRESOLUTION:
|
2014-12-21 10:15:31 -05:00
|
|
|
dblval = va_arg(ap, double);
|
|
|
|
if( dblval < 0 )
|
|
|
|
goto badvaluedouble;
|
2019-02-12 10:04:28 -05:00
|
|
|
td->td_xresolution = _TIFFClampDoubleToFloat( dblval );
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_YRESOLUTION:
|
2014-12-21 10:15:31 -05:00
|
|
|
dblval = va_arg(ap, double);
|
|
|
|
if( dblval < 0 )
|
|
|
|
goto badvaluedouble;
|
2019-02-12 10:04:28 -05:00
|
|
|
td->td_yresolution = _TIFFClampDoubleToFloat( dblval );
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_PLANARCONFIG:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
|
|
|
|
goto badvalue;
|
|
|
|
td->td_planarconfig = (uint16) v;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_XPOSITION:
|
2019-02-12 10:04:28 -05:00
|
|
|
td->td_xposition = _TIFFClampDoubleToFloat( va_arg(ap, double) );
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_YPOSITION:
|
2019-02-12 10:04:28 -05:00
|
|
|
td->td_yposition = _TIFFClampDoubleToFloat( va_arg(ap, double) );
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_RESOLUTIONUNIT:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
|
|
|
|
goto badvalue;
|
|
|
|
td->td_resolutionunit = (uint16) v;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_PAGENUMBER:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_pagenumber[0] = (uint16) va_arg(ap, uint16_vap);
|
|
|
|
td->td_pagenumber[1] = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_HALFTONEHINTS:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_halftonehints[0] = (uint16) va_arg(ap, uint16_vap);
|
|
|
|
td->td_halftonehints[1] = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_COLORMAP:
|
|
|
|
v32 = (uint32)(1L<<td->td_bitspersample);
|
|
|
|
_TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32);
|
|
|
|
_TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32);
|
|
|
|
_TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32);
|
|
|
|
break;
|
|
|
|
case TIFFTAG_EXTRASAMPLES:
|
2019-02-02 09:30:14 -05:00
|
|
|
if (!setExtraSamples(tif, ap, &v))
|
1999-07-27 17:50:26 -04:00
|
|
|
goto badvalue;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_MATTEING:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_extrasamples = (((uint16) va_arg(ap, uint16_vap)) != 0);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (td->td_extrasamples) {
|
|
|
|
uint16 sv = EXTRASAMPLE_ASSOCALPHA;
|
|
|
|
_TIFFsetShortArray(&td->td_sampleinfo, &sv, 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFFTAG_TILEWIDTH:
|
2007-04-18 20:51:47 -04:00
|
|
|
v32 = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v32 % 16) {
|
|
|
|
if (tif->tif_mode != O_RDONLY)
|
|
|
|
goto badvalue32;
|
2005-12-22 20:18:58 -05:00
|
|
|
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
|
|
|
|
"Nonstandard tile width %d, convert file", v32);
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
td->td_tilewidth = v32;
|
|
|
|
tif->tif_flags |= TIFF_ISTILED;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_TILELENGTH:
|
2007-04-18 20:51:47 -04:00
|
|
|
v32 = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v32 % 16) {
|
|
|
|
if (tif->tif_mode != O_RDONLY)
|
|
|
|
goto badvalue32;
|
2005-12-22 20:18:58 -05:00
|
|
|
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
|
1999-07-27 17:50:26 -04:00
|
|
|
"Nonstandard tile length %d, convert file", v32);
|
|
|
|
}
|
|
|
|
td->td_tilelength = v32;
|
|
|
|
tif->tif_flags |= TIFF_ISTILED;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_TILEDEPTH:
|
2007-04-18 20:51:47 -04:00
|
|
|
v32 = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (v32 == 0)
|
|
|
|
goto badvalue32;
|
|
|
|
td->td_tiledepth = v32;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_DATATYPE:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
switch (v) {
|
|
|
|
case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break;
|
|
|
|
case DATATYPE_INT: v = SAMPLEFORMAT_INT; break;
|
|
|
|
case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break;
|
|
|
|
case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break;
|
|
|
|
default: goto badvalue;
|
|
|
|
}
|
|
|
|
td->td_sampleformat = (uint16) v;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_SAMPLEFORMAT:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
2000-07-17 10:50:01 -04:00
|
|
|
if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
|
1999-07-27 17:50:26 -04:00
|
|
|
goto badvalue;
|
|
|
|
td->td_sampleformat = (uint16) v;
|
2003-02-26 15:38:49 -05:00
|
|
|
|
2007-04-18 20:51:47 -04:00
|
|
|
/* Try to fix up the SWAB function for complex data. */
|
|
|
|
if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT
|
|
|
|
&& td->td_bitspersample == 32
|
2007-03-30 21:04:52 -04:00
|
|
|
&& tif->tif_postdecode == _TIFFSwab32BitData )
|
2007-04-18 20:51:47 -04:00
|
|
|
tif->tif_postdecode = _TIFFSwab16BitData;
|
|
|
|
else if( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT
|
|
|
|
|| td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP)
|
|
|
|
&& td->td_bitspersample == 64
|
|
|
|
&& tif->tif_postdecode == _TIFFSwab64BitData )
|
|
|
|
tif->tif_postdecode = _TIFFSwab32BitData;
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_IMAGEDEPTH:
|
2007-04-18 20:51:47 -04:00
|
|
|
td->td_imagedepth = (uint32) va_arg(ap, uint32);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_SUBIFD:
|
|
|
|
if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_nsubifd = (uint16) va_arg(ap, uint16_vap);
|
2007-06-12 09:07:32 -04:00
|
|
|
_TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*),
|
2015-11-18 15:35:07 -05:00
|
|
|
(uint32) td->td_nsubifd);
|
1999-07-27 17:50:26 -04:00
|
|
|
} else {
|
2007-02-22 09:07:16 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"%s: Sorry, cannot nest SubIFDs",
|
|
|
|
tif->tif_name);
|
1999-07-27 17:50:26 -04:00
|
|
|
status = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFFTAG_YCBCRPOSITIONING:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_ycbcrpositioning = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_YCBCRSUBSAMPLING:
|
2007-06-27 08:28:15 -04:00
|
|
|
td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, uint16_vap);
|
|
|
|
td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_TRANSFERFUNCTION:
|
|
|
|
v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
|
|
|
|
for (i = 0; i < v; i++)
|
|
|
|
_TIFFsetShortArray(&td->td_transferfunction[i],
|
2015-11-18 15:35:07 -05:00
|
|
|
va_arg(ap, uint16*), 1U<<td->td_bitspersample);
|
1999-07-27 17:50:26 -04:00
|
|
|
break;
|
2009-11-30 13:19:15 -05:00
|
|
|
case TIFFTAG_REFERENCEBLACKWHITE:
|
|
|
|
/* XXX should check for null range */
|
|
|
|
_TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
|
|
|
|
break;
|
1999-07-27 17:50:26 -04:00
|
|
|
case TIFFTAG_INKNAMES:
|
2007-06-27 08:28:15 -04:00
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
1999-07-27 17:50:26 -04:00
|
|
|
s = va_arg(ap, char*);
|
2005-04-08 06:15:37 -04:00
|
|
|
v = checkInkNamesString(tif, v, s);
|
2007-04-18 20:51:47 -04:00
|
|
|
status = v > 0;
|
2005-04-08 06:15:37 -04:00
|
|
|
if( v > 0 ) {
|
|
|
|
_TIFFsetNString(&td->td_inknames, s, v);
|
|
|
|
td->td_inknameslen = v;
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
break;
|
2011-01-24 16:06:31 -05:00
|
|
|
case TIFFTAG_PERSAMPLE:
|
|
|
|
v = (uint16) va_arg(ap, uint16_vap);
|
|
|
|
if( v == PERSAMPLE_MULTI )
|
|
|
|
tif->tif_flags |= TIFF_PERSAMPLE;
|
|
|
|
else
|
|
|
|
tif->tif_flags &= ~TIFF_PERSAMPLE;
|
|
|
|
break;
|
2007-04-18 20:51:47 -04:00
|
|
|
default: {
|
2007-05-24 11:51:35 -04:00
|
|
|
TIFFTagValue *tv;
|
|
|
|
int tv_size, iCustom;
|
2002-02-24 10:40:57 -05:00
|
|
|
|
2007-05-24 11:51:35 -04:00
|
|
|
/*
|
|
|
|
* This can happen if multiple images are open with different
|
|
|
|
* codecs which have private tags. The global tag information
|
|
|
|
* table may then have tags that are valid for one file but not
|
|
|
|
* the other. If the client tries to set a tag that is not valid
|
|
|
|
* for the image's codec then we'll arrive here. This
|
|
|
|
* happens, for example, when tiffcp is used to convert between
|
|
|
|
* compression schemes and codec-specific tags are blindly copied.
|
|
|
|
*/
|
2014-11-20 11:47:21 -05:00
|
|
|
if(fip->field_bit != FIELD_CUSTOM) {
|
2007-05-24 11:51:35 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"%s: Invalid %stag \"%s\" (not supported by codec)",
|
|
|
|
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
|
2014-11-20 11:47:21 -05:00
|
|
|
fip->field_name);
|
2007-05-24 11:51:35 -04:00
|
|
|
status = 0;
|
|
|
|
break;
|
|
|
|
}
|
2002-02-24 10:40:57 -05:00
|
|
|
|
2007-05-24 11:51:35 -04:00
|
|
|
/*
|
|
|
|
* Find the existing entry for this custom value.
|
|
|
|
*/
|
|
|
|
tv = NULL;
|
|
|
|
for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++) {
|
|
|
|
if (td->td_customValues[iCustom].info->field_tag == tag) {
|
|
|
|
tv = td->td_customValues + iCustom;
|
|
|
|
if (tv->value != NULL) {
|
|
|
|
_TIFFfree(tv->value);
|
|
|
|
tv->value = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-11-30 15:42:14 -05:00
|
|
|
|
2007-05-24 11:51:35 -04:00
|
|
|
/*
|
|
|
|
* Grow the custom list if the entry was not found.
|
|
|
|
*/
|
|
|
|
if(tv == NULL) {
|
|
|
|
TIFFTagValue *new_customValues;
|
|
|
|
|
|
|
|
td->td_customValueCount++;
|
|
|
|
new_customValues = (TIFFTagValue *)
|
|
|
|
_TIFFrealloc(td->td_customValues,
|
|
|
|
sizeof(TIFFTagValue) * td->td_customValueCount);
|
|
|
|
if (!new_customValues) {
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"%s: Failed to allocate space for list of custom values",
|
|
|
|
tif->tif_name);
|
|
|
|
status = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
td->td_customValues = new_customValues;
|
|
|
|
|
|
|
|
tv = td->td_customValues + (td->td_customValueCount - 1);
|
|
|
|
tv->info = fip;
|
|
|
|
tv->value = NULL;
|
|
|
|
tv->count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set custom value ... save a copy of the custom tag value.
|
|
|
|
*/
|
|
|
|
tv_size = _TIFFDataSize(fip->field_type);
|
2019-12-19 16:04:44 -05:00
|
|
|
/*--: Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */
|
|
|
|
if (fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL) {
|
|
|
|
tv_size = _TIFFSetGetFieldSize(fip->set_field_type);
|
|
|
|
}
|
2007-05-24 11:51:35 -04:00
|
|
|
if (tv_size == 0) {
|
2004-09-25 07:05:58 -04:00
|
|
|
status = 0;
|
2007-05-24 11:51:35 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"%s: Bad field type %d for \"%s\"",
|
|
|
|
tif->tif_name, fip->field_type,
|
|
|
|
fip->field_name);
|
2004-09-25 07:05:58 -04:00
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2007-05-24 11:51:35 -04:00
|
|
|
if (fip->field_type == TIFF_ASCII)
|
|
|
|
{
|
|
|
|
uint32 ma;
|
|
|
|
char* mb;
|
|
|
|
if (fip->field_passcount)
|
|
|
|
{
|
|
|
|
assert(fip->field_writecount==TIFF_VARIABLE2);
|
|
|
|
ma=(uint32)va_arg(ap,uint32);
|
|
|
|
mb=(char*)va_arg(ap,char*);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mb=(char*)va_arg(ap,char*);
|
2007-06-26 08:31:25 -04:00
|
|
|
ma=(uint32)(strlen(mb)+1);
|
2007-05-24 11:51:35 -04:00
|
|
|
}
|
|
|
|
tv->count=ma;
|
|
|
|
setByteArray(&tv->value,mb,ma,1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-04-10 15:22:34 -04:00
|
|
|
if (fip->field_passcount) {
|
2007-05-24 11:51:35 -04:00
|
|
|
if (fip->field_writecount == TIFF_VARIABLE2)
|
|
|
|
tv->count = (uint32) va_arg(ap, uint32);
|
|
|
|
else
|
|
|
|
tv->count = (int) va_arg(ap, int);
|
|
|
|
} else if (fip->field_writecount == TIFF_VARIABLE
|
|
|
|
|| fip->field_writecount == TIFF_VARIABLE2)
|
|
|
|
tv->count = 1;
|
|
|
|
else if (fip->field_writecount == TIFF_SPP)
|
|
|
|
tv->count = td->td_samplesperpixel;
|
|
|
|
else
|
|
|
|
tv->count = fip->field_writecount;
|
2002-02-24 10:40:57 -05:00
|
|
|
|
2010-04-10 15:22:34 -04:00
|
|
|
if (tv->count == 0) {
|
|
|
|
status = 0;
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"%s: Null count for \"%s\" (type "
|
|
|
|
"%d, writecount %d, passcount %d)",
|
|
|
|
tif->tif_name,
|
|
|
|
fip->field_name,
|
|
|
|
fip->field_type,
|
|
|
|
fip->field_writecount,
|
|
|
|
fip->field_passcount);
|
|
|
|
goto end;
|
|
|
|
}
|
2002-11-30 15:42:14 -05:00
|
|
|
|
2010-04-10 15:22:34 -04:00
|
|
|
tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size,
|
|
|
|
"custom tag binary object");
|
2007-05-24 11:51:35 -04:00
|
|
|
if (!tv->value) {
|
|
|
|
status = 0;
|
|
|
|
goto end;
|
|
|
|
}
|
2005-03-17 09:43:14 -05:00
|
|
|
|
2012-06-06 00:56:01 -04:00
|
|
|
if (fip->field_tag == TIFFTAG_DOTRANGE
|
|
|
|
&& strcmp(fip->field_name,"DotRange") == 0) {
|
|
|
|
/* TODO: This is an evil exception and should not have been
|
|
|
|
handled this way ... likely best if we move it into
|
|
|
|
the directory structure with an explicit field in
|
|
|
|
libtiff 4.1 and assign it a FIELD_ value */
|
2015-10-17 06:13:14 -04:00
|
|
|
uint16 v2[2];
|
|
|
|
v2[0] = (uint16)va_arg(ap, int);
|
|
|
|
v2[1] = (uint16)va_arg(ap, int);
|
|
|
|
_TIFFmemcpy(tv->value, &v2, 4);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
else if (fip->field_passcount
|
|
|
|
|| fip->field_writecount == TIFF_VARIABLE
|
|
|
|
|| fip->field_writecount == TIFF_VARIABLE2
|
|
|
|
|| fip->field_writecount == TIFF_SPP
|
|
|
|
|| tv->count > 1) {
|
2019-12-19 16:04:44 -05:00
|
|
|
/*--: Rational2Double: For Rationals tv_size is set above to 4 or 8 according to fip->set_field_type! */
|
2007-05-24 11:51:35 -04:00
|
|
|
_TIFFmemcpy(tv->value, va_arg(ap, void *),
|
|
|
|
tv->count * tv_size);
|
|
|
|
} else {
|
|
|
|
char *val = (char *)tv->value;
|
2012-06-14 16:32:53 -04:00
|
|
|
assert( tv->count == 1 );
|
2006-02-03 10:58:42 -05:00
|
|
|
|
2012-06-06 00:56:01 -04:00
|
|
|
switch (fip->field_type) {
|
|
|
|
case TIFF_BYTE:
|
|
|
|
case TIFF_UNDEFINED:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
uint8 v2 = (uint8)va_arg(ap, int);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_SBYTE:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
int8 v2 = (int8)va_arg(ap, int);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_SHORT:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
uint16 v2 = (uint16)va_arg(ap, int);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2007-05-24 11:51:35 -04:00
|
|
|
}
|
2012-06-06 00:56:01 -04:00
|
|
|
break;
|
|
|
|
case TIFF_SSHORT:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
int16 v2 = (int16)va_arg(ap, int);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_LONG:
|
|
|
|
case TIFF_IFD:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
uint32 v2 = va_arg(ap, uint32);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_SLONG:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
int32 v2 = va_arg(ap, int32);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_LONG8:
|
|
|
|
case TIFF_IFD8:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
uint64 v2 = va_arg(ap, uint64);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_SLONG8:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
int64 v2 = va_arg(ap, int64);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_RATIONAL:
|
|
|
|
case TIFF_SRATIONAL:
|
2019-12-19 16:04:44 -05:00
|
|
|
/*-- Rational2Double: For Rationals tv_size is set above to 4 or 8 according to fip->set_field_type! */
|
|
|
|
{
|
|
|
|
if (tv_size == 8) {
|
|
|
|
double v2 = va_arg(ap, double);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
|
|
|
} else {
|
2020-02-28 19:17:17 -05:00
|
|
|
/*-- default should be tv_size == 4 */
|
2019-12-19 16:04:44 -05:00
|
|
|
float v3 = (float)va_arg(ap, double);
|
|
|
|
_TIFFmemcpy(val, &v3, tv_size);
|
|
|
|
/*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */
|
|
|
|
if (tv_size != 4) {
|
|
|
|
TIFFErrorExt(0,"TIFFLib: _TIFFVSetField()", "Rational2Double: .set_field_type in not 4 but %d", tv_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-06-06 00:56:01 -04:00
|
|
|
case TIFF_FLOAT:
|
|
|
|
{
|
2019-02-12 10:04:28 -05:00
|
|
|
float v2 = _TIFFClampDoubleToFloat(va_arg(ap, double));
|
2015-10-17 06:13:14 -04:00
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFF_DOUBLE:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
double v2 = va_arg(ap, double);
|
|
|
|
_TIFFmemcpy(val, &v2, tv_size);
|
2012-06-06 00:56:01 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_TIFFmemset(val, 0, tv_size);
|
|
|
|
status = 0;
|
|
|
|
break;
|
2007-05-24 11:51:35 -04:00
|
|
|
}
|
|
|
|
}
|
2003-06-30 14:25:50 -04:00
|
|
|
}
|
2007-05-24 11:51:35 -04:00
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
if (status) {
|
2015-10-17 06:13:14 -04:00
|
|
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
|
|
|
if (fip2)
|
|
|
|
TIFFSetFieldBit(tif, fip2->field_bit);
|
2005-03-21 05:17:37 -05:00
|
|
|
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
2004-09-25 07:05:58 -04:00
|
|
|
|
|
|
|
end:
|
1999-07-27 17:50:26 -04:00
|
|
|
va_end(ap);
|
|
|
|
return (status);
|
|
|
|
badvalue:
|
2012-01-31 20:51:00 -05:00
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
2012-01-31 20:51:00 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
2008-12-31 18:48:01 -05:00
|
|
|
"%s: Bad value %u for \"%s\" tag",
|
2007-04-07 11:21:10 -04:00
|
|
|
tif->tif_name, v,
|
2015-10-17 06:13:14 -04:00
|
|
|
fip2 ? fip2->field_name : "Unknown");
|
2012-01-31 20:51:00 -05:00
|
|
|
va_end(ap);
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
return (0);
|
|
|
|
badvalue32:
|
2012-01-31 20:51:00 -05:00
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
2012-01-31 20:51:00 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
2008-12-31 18:48:01 -05:00
|
|
|
"%s: Bad value %u for \"%s\" tag",
|
2007-04-07 11:21:10 -04:00
|
|
|
tif->tif_name, v32,
|
2015-10-17 06:13:14 -04:00
|
|
|
fip2 ? fip2->field_name : "Unknown");
|
2012-01-31 20:51:00 -05:00
|
|
|
va_end(ap);
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
return (0);
|
2014-12-21 10:15:31 -05:00
|
|
|
badvaluedouble:
|
|
|
|
{
|
2015-10-17 06:13:14 -04:00
|
|
|
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
|
2014-12-21 10:15:31 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"%s: Bad value %f for \"%s\" tag",
|
|
|
|
tif->tif_name, dblval,
|
2015-10-17 06:13:14 -04:00
|
|
|
fip2 ? fip2->field_name : "Unknown");
|
2014-12-21 10:15:31 -05:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
return (0);
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return 1/0 according to whether or not
|
|
|
|
* it is permissible to set the tag's value.
|
|
|
|
* Note that we allow ImageLength to be changed
|
|
|
|
* so that we can append and extend to images.
|
|
|
|
* Any other tag may not be altered once writing
|
|
|
|
* has commenced, unless its value has no effect
|
|
|
|
* on the format of the data that is written.
|
|
|
|
*/
|
|
|
|
static int
|
2007-04-04 00:16:07 -04:00
|
|
|
OkToChangeTag(TIFF* tif, uint32 tag)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2007-07-09 06:15:37 -04:00
|
|
|
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
|
1999-07-27 17:50:26 -04:00
|
|
|
if (!fip) { /* unknown tag */
|
2005-12-21 07:23:13 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u",
|
1999-07-27 17:50:26 -04:00
|
|
|
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
|
|
|
|
!fip->field_oktochange) {
|
|
|
|
/*
|
|
|
|
* Consult info table to see if tag can be changed
|
|
|
|
* after we've started writing. We only allow changes
|
|
|
|
* to those tags that don't/shouldn't affect the
|
|
|
|
* compression and/or format of the data.
|
|
|
|
*/
|
2005-12-21 07:23:13 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
|
1999-07-27 17:50:26 -04:00
|
|
|
"%s: Cannot modify tag \"%s\" while writing",
|
|
|
|
tif->tif_name, fip->field_name);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Record the value of a field in the
|
|
|
|
* internal directory structure. The
|
|
|
|
* field will be written to the file
|
|
|
|
* when/if the directory structure is
|
|
|
|
* updated.
|
|
|
|
*/
|
|
|
|
int
|
2007-04-04 00:16:07 -04:00
|
|
|
TIFFSetField(TIFF* tif, uint32 tag, ...)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
va_start(ap, tag);
|
|
|
|
status = TIFFVSetField(tif, tag, ap);
|
|
|
|
va_end(ap);
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
2008-12-21 15:30:25 -05:00
|
|
|
/*
|
|
|
|
* Clear the contents of the field in the internal structure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
TIFFUnsetField(TIFF* tif, uint32 tag)
|
|
|
|
{
|
|
|
|
const TIFFField *fip = TIFFFieldWithTag(tif, tag);
|
|
|
|
TIFFDirectory* td = &tif->tif_dir;
|
|
|
|
|
|
|
|
if( !fip )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if( fip->field_bit != FIELD_CUSTOM )
|
|
|
|
TIFFClrFieldBit(tif, fip->field_bit);
|
|
|
|
else
|
|
|
|
{
|
2009-01-23 00:25:19 -05:00
|
|
|
TIFFTagValue *tv = NULL;
|
2008-12-21 15:30:25 -05:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < td->td_customValueCount; i++) {
|
|
|
|
|
|
|
|
tv = td->td_customValues + i;
|
|
|
|
if( tv->info->field_tag == tag )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( i < td->td_customValueCount )
|
|
|
|
{
|
|
|
|
_TIFFfree(tv->value);
|
|
|
|
for( ; i < td->td_customValueCount-1; i++) {
|
|
|
|
td->td_customValues[i] = td->td_customValues[i+1];
|
|
|
|
}
|
|
|
|
td->td_customValueCount--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tif->tif_flags |= TIFF_DIRTYDIRECT;
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
/*
|
|
|
|
* Like TIFFSetField, but taking a varargs
|
|
|
|
* parameter list. This routine is useful
|
|
|
|
* for building higher-level interfaces on
|
|
|
|
* top of the library.
|
|
|
|
*/
|
|
|
|
int
|
2007-04-04 00:16:07 -04:00
|
|
|
TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
|
|
|
return OkToChangeTag(tif, tag) ?
|
2002-02-24 10:40:57 -05:00
|
|
|
(*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0;
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-04-04 00:16:07 -04:00
|
|
|
_TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2007-06-26 05:42:27 -04:00
|
|
|
TIFFDirectory* td = &tif->tif_dir;
|
|
|
|
int ret_val = 1;
|
2012-05-30 00:58:13 -04:00
|
|
|
uint32 standard_tag = tag;
|
|
|
|
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
|
2014-11-20 11:47:21 -05:00
|
|
|
if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
|
|
|
|
return 0;
|
2017-12-31 09:30:44 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to force the custom code to be used for custom
|
|
|
|
* fields even if the tag happens to match a well known
|
|
|
|
* one - important for reinterpreted handling of standard
|
|
|
|
* tag values in custom directories (i.e. EXIF)
|
|
|
|
*/
|
|
|
|
if (fip->field_bit == FIELD_CUSTOM) {
|
|
|
|
standard_tag = 0;
|
|
|
|
}
|
2012-05-30 00:58:13 -04:00
|
|
|
|
2017-12-31 09:30:44 -05:00
|
|
|
if( standard_tag == TIFFTAG_NUMBEROFINKS )
|
2016-12-03 10:30:31 -05:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < td->td_customValueCount; i++) {
|
|
|
|
uint16 val;
|
|
|
|
TIFFTagValue *tv = td->td_customValues + i;
|
2017-12-31 09:30:44 -05:00
|
|
|
if (tv->info->field_tag != standard_tag)
|
2016-12-03 10:30:31 -05:00
|
|
|
continue;
|
2017-07-11 17:38:04 -04:00
|
|
|
if( tv->value == NULL )
|
|
|
|
return 0;
|
2016-12-03 10:30:31 -05:00
|
|
|
val = *(uint16 *)tv->value;
|
|
|
|
/* Truncate to SamplesPerPixel, since the */
|
|
|
|
/* setting code for INKNAMES assume that there are SamplesPerPixel */
|
|
|
|
/* inknames. */
|
|
|
|
/* Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2599 */
|
|
|
|
if( val > td->td_samplesperpixel )
|
|
|
|
{
|
|
|
|
TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField",
|
|
|
|
"Truncating NumberOfInks from %u to %u",
|
|
|
|
val, td->td_samplesperpixel);
|
|
|
|
val = td->td_samplesperpixel;
|
|
|
|
}
|
|
|
|
*va_arg(ap, uint16*) = val;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-30 00:58:13 -04:00
|
|
|
switch (standard_tag) {
|
2007-06-26 05:42:27 -04:00
|
|
|
case TIFFTAG_SUBFILETYPE:
|
|
|
|
*va_arg(ap, uint32*) = td->td_subfiletype;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_IMAGEWIDTH:
|
|
|
|
*va_arg(ap, uint32*) = td->td_imagewidth;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_IMAGELENGTH:
|
|
|
|
*va_arg(ap, uint32*) = td->td_imagelength;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_BITSPERSAMPLE:
|
|
|
|
*va_arg(ap, uint16*) = td->td_bitspersample;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_COMPRESSION:
|
|
|
|
*va_arg(ap, uint16*) = td->td_compression;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_PHOTOMETRIC:
|
|
|
|
*va_arg(ap, uint16*) = td->td_photometric;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_THRESHHOLDING:
|
|
|
|
*va_arg(ap, uint16*) = td->td_threshholding;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_FILLORDER:
|
|
|
|
*va_arg(ap, uint16*) = td->td_fillorder;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_ORIENTATION:
|
|
|
|
*va_arg(ap, uint16*) = td->td_orientation;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_SAMPLESPERPIXEL:
|
|
|
|
*va_arg(ap, uint16*) = td->td_samplesperpixel;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_ROWSPERSTRIP:
|
|
|
|
*va_arg(ap, uint32*) = td->td_rowsperstrip;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_MINSAMPLEVALUE:
|
|
|
|
*va_arg(ap, uint16*) = td->td_minsamplevalue;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_MAXSAMPLEVALUE:
|
|
|
|
*va_arg(ap, uint16*) = td->td_maxsamplevalue;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_SMINSAMPLEVALUE:
|
2011-01-24 16:06:31 -05:00
|
|
|
if (tif->tif_flags & TIFF_PERSAMPLE)
|
|
|
|
*va_arg(ap, double**) = td->td_sminsamplevalue;
|
|
|
|
else
|
|
|
|
{
|
2016-01-23 16:20:34 -05:00
|
|
|
/* libtiff historically treats this as a single value. */
|
2011-01-24 16:06:31 -05:00
|
|
|
uint16 i;
|
|
|
|
double v = td->td_sminsamplevalue[0];
|
|
|
|
for (i=1; i < td->td_samplesperpixel; ++i)
|
|
|
|
if( td->td_sminsamplevalue[i] < v )
|
|
|
|
v = td->td_sminsamplevalue[i];
|
|
|
|
*va_arg(ap, double*) = v;
|
|
|
|
}
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_SMAXSAMPLEVALUE:
|
2011-01-24 16:06:31 -05:00
|
|
|
if (tif->tif_flags & TIFF_PERSAMPLE)
|
|
|
|
*va_arg(ap, double**) = td->td_smaxsamplevalue;
|
|
|
|
else
|
|
|
|
{
|
2016-01-23 16:20:34 -05:00
|
|
|
/* libtiff historically treats this as a single value. */
|
2011-01-24 16:06:31 -05:00
|
|
|
uint16 i;
|
|
|
|
double v = td->td_smaxsamplevalue[0];
|
|
|
|
for (i=1; i < td->td_samplesperpixel; ++i)
|
|
|
|
if( td->td_smaxsamplevalue[i] > v )
|
|
|
|
v = td->td_smaxsamplevalue[i];
|
|
|
|
*va_arg(ap, double*) = v;
|
|
|
|
}
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_XRESOLUTION:
|
|
|
|
*va_arg(ap, float*) = td->td_xresolution;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_YRESOLUTION:
|
|
|
|
*va_arg(ap, float*) = td->td_yresolution;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_PLANARCONFIG:
|
|
|
|
*va_arg(ap, uint16*) = td->td_planarconfig;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_XPOSITION:
|
|
|
|
*va_arg(ap, float*) = td->td_xposition;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_YPOSITION:
|
|
|
|
*va_arg(ap, float*) = td->td_yposition;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_RESOLUTIONUNIT:
|
|
|
|
*va_arg(ap, uint16*) = td->td_resolutionunit;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_PAGENUMBER:
|
|
|
|
*va_arg(ap, uint16*) = td->td_pagenumber[0];
|
|
|
|
*va_arg(ap, uint16*) = td->td_pagenumber[1];
|
|
|
|
break;
|
|
|
|
case TIFFTAG_HALFTONEHINTS:
|
|
|
|
*va_arg(ap, uint16*) = td->td_halftonehints[0];
|
|
|
|
*va_arg(ap, uint16*) = td->td_halftonehints[1];
|
|
|
|
break;
|
|
|
|
case TIFFTAG_COLORMAP:
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint16**) = td->td_colormap[0];
|
|
|
|
*va_arg(ap, const uint16**) = td->td_colormap[1];
|
|
|
|
*va_arg(ap, const uint16**) = td->td_colormap[2];
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_STRIPOFFSETS:
|
|
|
|
case TIFFTAG_TILEOFFSETS:
|
2011-02-18 15:53:04 -05:00
|
|
|
_TIFFFillStriles( tif );
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint64**) = td->td_stripoffset_p;
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_STRIPBYTECOUNTS:
|
|
|
|
case TIFFTAG_TILEBYTECOUNTS:
|
2011-02-18 15:53:04 -05:00
|
|
|
_TIFFFillStriles( tif );
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint64**) = td->td_stripbytecount_p;
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_MATTEING:
|
|
|
|
*va_arg(ap, uint16*) =
|
|
|
|
(td->td_extrasamples == 1 &&
|
|
|
|
td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
|
|
|
|
break;
|
|
|
|
case TIFFTAG_EXTRASAMPLES:
|
|
|
|
*va_arg(ap, uint16*) = td->td_extrasamples;
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint16**) = td->td_sampleinfo;
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_TILEWIDTH:
|
|
|
|
*va_arg(ap, uint32*) = td->td_tilewidth;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_TILELENGTH:
|
|
|
|
*va_arg(ap, uint32*) = td->td_tilelength;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_TILEDEPTH:
|
|
|
|
*va_arg(ap, uint32*) = td->td_tiledepth;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_DATATYPE:
|
|
|
|
switch (td->td_sampleformat) {
|
|
|
|
case SAMPLEFORMAT_UINT:
|
|
|
|
*va_arg(ap, uint16*) = DATATYPE_UINT;
|
|
|
|
break;
|
|
|
|
case SAMPLEFORMAT_INT:
|
|
|
|
*va_arg(ap, uint16*) = DATATYPE_INT;
|
|
|
|
break;
|
|
|
|
case SAMPLEFORMAT_IEEEFP:
|
|
|
|
*va_arg(ap, uint16*) = DATATYPE_IEEEFP;
|
|
|
|
break;
|
|
|
|
case SAMPLEFORMAT_VOID:
|
|
|
|
*va_arg(ap, uint16*) = DATATYPE_VOID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TIFFTAG_SAMPLEFORMAT:
|
|
|
|
*va_arg(ap, uint16*) = td->td_sampleformat;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_IMAGEDEPTH:
|
|
|
|
*va_arg(ap, uint32*) = td->td_imagedepth;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_SUBIFD:
|
|
|
|
*va_arg(ap, uint16*) = td->td_nsubifd;
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint64**) = td->td_subifd;
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
case TIFFTAG_YCBCRPOSITIONING:
|
|
|
|
*va_arg(ap, uint16*) = td->td_ycbcrpositioning;
|
|
|
|
break;
|
|
|
|
case TIFFTAG_YCBCRSUBSAMPLING:
|
|
|
|
*va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0];
|
|
|
|
*va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
|
|
|
|
break;
|
|
|
|
case TIFFTAG_TRANSFERFUNCTION:
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint16**) = td->td_transferfunction[0];
|
2007-06-26 05:42:27 -04:00
|
|
|
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint16**) = td->td_transferfunction[1];
|
|
|
|
*va_arg(ap, const uint16**) = td->td_transferfunction[2];
|
tiff2pdf: Fix CVE-2017-9935
Fix for http://bugzilla.maptools.org/show_bug.cgi?id=2704
This vulnerability - at least for the supplied test case - is because we
assume that a tiff will only have one transfer function that is the same
for all pages. This is not required by the TIFF standards.
We than read the transfer function for every page. Depending on the
transfer function, we allocate either 2 or 4 bytes to the XREF buffer.
We allocate this memory after we read in the transfer function for the
page.
For the first exploit - POC1, this file has 3 pages. For the first page
we allocate 2 extra extra XREF entries. Then for the next page 2 more
entries. Then for the last page the transfer function changes and we
allocate 4 more entries.
When we read the file into memory, we assume we have 4 bytes extra for
each and every page (as per the last transfer function we read). Which
is not correct, we only have 2 bytes extra for the first 2 pages. As a
result, we end up writing past the end of the buffer.
There are also some related issues that this also fixes. For example,
TIFFGetField can return uninitalized pointer values, and the logic to
detect a N=3 vs N=1 transfer function seemed rather strange.
It is also strange that we declare the transfer functions to be of type
float, when the standard says they are unsigned 16 bit values. This is
fixed in another patch.
This patch will check to ensure that the N value for every transfer
function is the same for every page. If this changes, we abort with an
error. In theory, we should perhaps check that the transfer function
itself is identical for every page, however we don't do that due to the
confusion of the type of the data in the transfer function.
2017-12-06 15:46:47 -05:00
|
|
|
} else {
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const uint16**) = NULL;
|
|
|
|
*va_arg(ap, const uint16**) = NULL;
|
2007-06-26 05:42:27 -04:00
|
|
|
}
|
|
|
|
break;
|
2009-11-30 13:19:15 -05:00
|
|
|
case TIFFTAG_REFERENCEBLACKWHITE:
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const float**) = td->td_refblackwhite;
|
2009-11-30 13:19:15 -05:00
|
|
|
break;
|
2007-06-26 05:42:27 -04:00
|
|
|
case TIFFTAG_INKNAMES:
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const char**) = td->td_inknames;
|
2007-06-26 05:42:27 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
2007-07-09 06:15:37 -04:00
|
|
|
* This can happen if multiple images are open
|
|
|
|
* with different codecs which have private
|
|
|
|
* tags. The global tag information table may
|
|
|
|
* then have tags that are valid for one file
|
|
|
|
* but not the other. If the client tries to
|
|
|
|
* get a tag that is not valid for the image's
|
|
|
|
* codec then we'll arrive here.
|
2007-06-26 05:42:27 -04:00
|
|
|
*/
|
2014-11-20 11:47:21 -05:00
|
|
|
if( fip->field_bit != FIELD_CUSTOM )
|
2007-06-26 05:42:27 -04:00
|
|
|
{
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
|
|
|
|
"%s: Invalid %stag \"%s\" "
|
|
|
|
"(not supported by codec)",
|
|
|
|
tif->tif_name,
|
|
|
|
isPseudoTag(tag) ? "pseudo-" : "",
|
2014-11-20 11:47:21 -05:00
|
|
|
fip->field_name);
|
2007-06-26 05:42:27 -04:00
|
|
|
ret_val = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do we have a custom value?
|
|
|
|
*/
|
|
|
|
ret_val = 0;
|
|
|
|
for (i = 0; i < td->td_customValueCount; i++) {
|
|
|
|
TIFFTagValue *tv = td->td_customValues + i;
|
|
|
|
|
|
|
|
if (tv->info->field_tag != tag)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (fip->field_passcount) {
|
|
|
|
if (fip->field_readcount == TIFF_VARIABLE2)
|
|
|
|
*va_arg(ap, uint32*) = (uint32)tv->count;
|
|
|
|
else /* Assume TIFF_VARIABLE */
|
|
|
|
*va_arg(ap, uint16*) = (uint16)tv->count;
|
2020-03-07 18:51:28 -05:00
|
|
|
*va_arg(ap, const void **) = tv->value;
|
2005-03-21 05:17:37 -05:00
|
|
|
ret_val = 1;
|
2012-06-06 00:56:01 -04:00
|
|
|
} else if (fip->field_tag == TIFFTAG_DOTRANGE
|
|
|
|
&& strcmp(fip->field_name,"DotRange") == 0) {
|
|
|
|
/* TODO: This is an evil exception and should not have been
|
|
|
|
handled this way ... likely best if we move it into
|
|
|
|
the directory structure with an explicit field in
|
|
|
|
libtiff 4.1 and assign it a FIELD_ value */
|
|
|
|
*va_arg(ap, uint16*) = ((uint16 *)tv->value)[0];
|
|
|
|
*va_arg(ap, uint16*) = ((uint16 *)tv->value)[1];
|
|
|
|
ret_val = 1;
|
2007-06-26 05:42:27 -04:00
|
|
|
} else {
|
2012-06-06 00:56:01 -04:00
|
|
|
if (fip->field_type == TIFF_ASCII
|
2007-06-26 05:42:27 -04:00
|
|
|
|| fip->field_readcount == TIFF_VARIABLE
|
|
|
|
|| fip->field_readcount == TIFF_VARIABLE2
|
|
|
|
|| fip->field_readcount == TIFF_SPP
|
2012-06-06 00:56:01 -04:00
|
|
|
|| tv->count > 1) {
|
2007-06-26 05:42:27 -04:00
|
|
|
*va_arg(ap, void **) = tv->value;
|
|
|
|
ret_val = 1;
|
|
|
|
} else {
|
|
|
|
char *val = (char *)tv->value;
|
2012-06-06 00:56:01 -04:00
|
|
|
assert( tv->count == 1 );
|
|
|
|
switch (fip->field_type) {
|
|
|
|
case TIFF_BYTE:
|
|
|
|
case TIFF_UNDEFINED:
|
|
|
|
*va_arg(ap, uint8*) =
|
|
|
|
*(uint8 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_SBYTE:
|
|
|
|
*va_arg(ap, int8*) =
|
|
|
|
*(int8 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_SHORT:
|
|
|
|
*va_arg(ap, uint16*) =
|
|
|
|
*(uint16 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_SSHORT:
|
|
|
|
*va_arg(ap, int16*) =
|
|
|
|
*(int16 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_LONG:
|
|
|
|
case TIFF_IFD:
|
|
|
|
*va_arg(ap, uint32*) =
|
|
|
|
*(uint32 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_SLONG:
|
|
|
|
*va_arg(ap, int32*) =
|
|
|
|
*(int32 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_LONG8:
|
|
|
|
case TIFF_IFD8:
|
|
|
|
*va_arg(ap, uint64*) =
|
|
|
|
*(uint64 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_SLONG8:
|
|
|
|
*va_arg(ap, int64*) =
|
|
|
|
*(int64 *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_RATIONAL:
|
|
|
|
case TIFF_SRATIONAL:
|
2019-12-19 16:04:44 -05:00
|
|
|
{
|
|
|
|
/*-- Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size and return value size. */
|
|
|
|
int tv_size = _TIFFSetGetFieldSize(fip->set_field_type);
|
|
|
|
if (tv_size == 8) {
|
|
|
|
*va_arg(ap, double*) = *(double *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
} else {
|
2020-02-28 19:17:17 -05:00
|
|
|
/*-- default should be tv_size == 4 */
|
2019-12-19 16:04:44 -05:00
|
|
|
*va_arg(ap, float*) = *(float *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
/*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */
|
|
|
|
if (tv_size != 4) {
|
|
|
|
TIFFErrorExt(0,"TIFFLib: _TIFFVGetField()", "Rational2Double: .set_field_type in not 4 but %d", tv_size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2012-06-06 00:56:01 -04:00
|
|
|
case TIFF_FLOAT:
|
|
|
|
*va_arg(ap, float*) =
|
|
|
|
*(float *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
case TIFF_DOUBLE:
|
|
|
|
*va_arg(ap, double*) =
|
|
|
|
*(double *)val;
|
|
|
|
ret_val = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret_val = 0;
|
|
|
|
break;
|
2007-06-26 05:42:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-03-18 08:29:39 -05:00
|
|
|
}
|
2005-03-17 09:43:14 -05:00
|
|
|
}
|
2007-06-26 05:42:27 -04:00
|
|
|
}
|
|
|
|
return(ret_val);
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the value of a field in the
|
|
|
|
* internal directory structure.
|
|
|
|
*/
|
|
|
|
int
|
2007-04-04 00:16:07 -04:00
|
|
|
TIFFGetField(TIFF* tif, uint32 tag, ...)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, tag);
|
|
|
|
status = TIFFVGetField(tif, tag, ap);
|
|
|
|
va_end(ap);
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Like TIFFGetField, but taking a varargs
|
|
|
|
* parameter list. This routine is useful
|
|
|
|
* for building higher-level interfaces on
|
|
|
|
* top of the library.
|
|
|
|
*/
|
|
|
|
int
|
2007-04-04 00:16:07 -04:00
|
|
|
TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2007-07-09 06:15:37 -04:00
|
|
|
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
|
1999-07-27 17:50:26 -04:00
|
|
|
return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ?
|
2002-02-24 10:40:57 -05:00
|
|
|
(*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0);
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define CleanupField(member) { \
|
|
|
|
if (td->member) { \
|
|
|
|
_TIFFfree(td->member); \
|
|
|
|
td->member = 0; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release storage associated with a directory.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
TIFFFreeDirectory(TIFF* tif)
|
|
|
|
{
|
2004-09-21 10:44:06 -04:00
|
|
|
TIFFDirectory *td = &tif->tif_dir;
|
|
|
|
int i;
|
1999-07-27 17:50:26 -04:00
|
|
|
|
2005-12-09 09:46:43 -05:00
|
|
|
_TIFFmemset(td->td_fieldsset, 0, FIELD_SETLONGS);
|
2011-01-24 16:06:31 -05:00
|
|
|
CleanupField(td_sminsamplevalue);
|
|
|
|
CleanupField(td_smaxsamplevalue);
|
2004-09-21 10:44:06 -04:00
|
|
|
CleanupField(td_colormap[0]);
|
|
|
|
CleanupField(td_colormap[1]);
|
|
|
|
CleanupField(td_colormap[2]);
|
|
|
|
CleanupField(td_sampleinfo);
|
|
|
|
CleanupField(td_subifd);
|
|
|
|
CleanupField(td_inknames);
|
2009-11-30 13:19:15 -05:00
|
|
|
CleanupField(td_refblackwhite);
|
2004-09-21 10:44:06 -04:00
|
|
|
CleanupField(td_transferfunction[0]);
|
|
|
|
CleanupField(td_transferfunction[1]);
|
|
|
|
CleanupField(td_transferfunction[2]);
|
2019-05-10 08:46:45 -04:00
|
|
|
CleanupField(td_stripoffset_p);
|
|
|
|
CleanupField(td_stripbytecount_p);
|
|
|
|
td->td_stripoffsetbyteallocsize = 0;
|
2006-02-03 11:36:02 -05:00
|
|
|
TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING);
|
|
|
|
TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING);
|
2002-02-24 10:40:57 -05:00
|
|
|
|
2004-09-21 10:44:06 -04:00
|
|
|
/* Cleanup custom tag values */
|
|
|
|
for( i = 0; i < td->td_customValueCount; i++ ) {
|
|
|
|
if (td->td_customValues[i].value)
|
|
|
|
_TIFFfree(td->td_customValues[i].value);
|
|
|
|
}
|
2004-01-11 10:14:02 -05:00
|
|
|
|
2004-09-21 10:44:06 -04:00
|
|
|
td->td_customValueCount = 0;
|
|
|
|
CleanupField(td_customValues);
|
2011-02-18 15:53:04 -05:00
|
|
|
|
|
|
|
_TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
|
|
|
|
_TIFFmemset( &(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
#undef CleanupField
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Client Tag extension support (from Niles Ritter).
|
|
|
|
*/
|
|
|
|
static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL;
|
|
|
|
|
|
|
|
TIFFExtendProc
|
|
|
|
TIFFSetTagExtender(TIFFExtendProc extender)
|
|
|
|
{
|
|
|
|
TIFFExtendProc prev = _TIFFextender;
|
|
|
|
_TIFFextender = extender;
|
|
|
|
return (prev);
|
|
|
|
}
|
|
|
|
|
2000-01-28 10:12:17 -05:00
|
|
|
/*
|
|
|
|
* Setup for a new directory. Should we automatically call
|
|
|
|
* TIFFWriteDirectory() if the current one is dirty?
|
|
|
|
*
|
|
|
|
* The newly created directory will not exist on the file till
|
|
|
|
* TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
TIFFCreateDirectory(TIFF* tif)
|
|
|
|
{
|
2007-06-26 05:42:27 -04:00
|
|
|
TIFFDefaultDirectory(tif);
|
|
|
|
tif->tif_diroff = 0;
|
|
|
|
tif->tif_nextdiroff = 0;
|
|
|
|
tif->tif_curoff = 0;
|
|
|
|
tif->tif_row = (uint32) -1;
|
|
|
|
tif->tif_curstrip = (uint32) -1;
|
|
|
|
|
|
|
|
return 0;
|
2000-01-28 10:12:17 -05:00
|
|
|
}
|
|
|
|
|
2012-06-06 00:58:00 -04:00
|
|
|
int
|
|
|
|
TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray)
|
|
|
|
{
|
|
|
|
TIFFDefaultDirectory(tif);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset the field definitions to match the application provided list.
|
|
|
|
* Hopefully TIFFDefaultDirectory() won't have done anything irreversable
|
|
|
|
* based on it's assumption this is an image directory.
|
|
|
|
*/
|
|
|
|
_TIFFSetupFields(tif, infoarray);
|
|
|
|
|
|
|
|
tif->tif_diroff = 0;
|
|
|
|
tif->tif_nextdiroff = 0;
|
|
|
|
tif->tif_curoff = 0;
|
|
|
|
tif->tif_row = (uint32) -1;
|
|
|
|
tif->tif_curstrip = (uint32) -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
TIFFCreateEXIFDirectory(TIFF* tif)
|
|
|
|
{
|
|
|
|
const TIFFFieldArray* exifFieldArray;
|
|
|
|
exifFieldArray = _TIFFGetExifFields();
|
|
|
|
return TIFFCreateCustomDirectory(tif, exifFieldArray);
|
|
|
|
}
|
|
|
|
|
2020-03-02 16:50:05 -05:00
|
|
|
/*
|
|
|
|
* Creates the EXIF GPS custom directory
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
TIFFCreateGPSDirectory(TIFF* tif)
|
|
|
|
{
|
|
|
|
const TIFFFieldArray* gpsFieldArray;
|
|
|
|
gpsFieldArray = _TIFFGetGpsFields();
|
|
|
|
return TIFFCreateCustomDirectory(tif, gpsFieldArray);
|
|
|
|
}
|
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
/*
|
|
|
|
* Setup a default directory structure.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
TIFFDefaultDirectory(TIFF* tif)
|
|
|
|
{
|
|
|
|
register TIFFDirectory* td = &tif->tif_dir;
|
2007-07-12 09:59:34 -04:00
|
|
|
const TIFFFieldArray* tiffFieldArray;
|
1999-07-27 17:50:26 -04:00
|
|
|
|
2007-07-12 09:59:34 -04:00
|
|
|
tiffFieldArray = _TIFFGetFields();
|
|
|
|
_TIFFSetupFields(tif, tiffFieldArray);
|
2005-12-26 09:31:24 -05:00
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
_TIFFmemset(td, 0, sizeof (*td));
|
|
|
|
td->td_fillorder = FILLORDER_MSB2LSB;
|
|
|
|
td->td_bitspersample = 1;
|
|
|
|
td->td_threshholding = THRESHHOLD_BILEVEL;
|
|
|
|
td->td_orientation = ORIENTATION_TOPLEFT;
|
|
|
|
td->td_samplesperpixel = 1;
|
|
|
|
td->td_rowsperstrip = (uint32) -1;
|
2004-10-09 14:33:56 -04:00
|
|
|
td->td_tilewidth = 0;
|
|
|
|
td->td_tilelength = 0;
|
1999-07-27 17:50:26 -04:00
|
|
|
td->td_tiledepth = 1;
|
2019-05-10 08:46:45 -04:00
|
|
|
#ifdef STRIPBYTECOUNTSORTED_UNUSED
|
2007-03-30 21:04:52 -04:00
|
|
|
td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
|
2019-05-10 08:46:45 -04:00
|
|
|
#endif
|
1999-07-27 17:50:26 -04:00
|
|
|
td->td_resolutionunit = RESUNIT_INCH;
|
2000-03-03 10:15:57 -05:00
|
|
|
td->td_sampleformat = SAMPLEFORMAT_UINT;
|
1999-07-27 17:50:26 -04:00
|
|
|
td->td_imagedepth = 1;
|
|
|
|
td->td_ycbcrsubsampling[0] = 2;
|
|
|
|
td->td_ycbcrsubsampling[1] = 2;
|
|
|
|
td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED;
|
2007-03-30 21:04:52 -04:00
|
|
|
tif->tif_postdecode = _TIFFNoPostDecode;
|
2006-03-24 22:09:24 -05:00
|
|
|
tif->tif_foundfield = NULL;
|
2007-04-18 20:51:47 -04:00
|
|
|
tif->tif_tagmethods.vsetfield = _TIFFVSetField;
|
2002-02-24 10:40:57 -05:00
|
|
|
tif->tif_tagmethods.vgetfield = _TIFFVGetField;
|
|
|
|
tif->tif_tagmethods.printdir = NULL;
|
1999-07-27 17:50:26 -04:00
|
|
|
/*
|
|
|
|
* Give client code a chance to install their own
|
2014-12-27 10:20:42 -05:00
|
|
|
* tag extensions & methods, prior to compression overloads,
|
|
|
|
* but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054)
|
1999-07-27 17:50:26 -04:00
|
|
|
*/
|
2014-12-27 10:20:42 -05:00
|
|
|
if (tif->tif_nfieldscompat > 0) {
|
|
|
|
uint32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < tif->tif_nfieldscompat; i++) {
|
|
|
|
if (tif->tif_fieldscompat[i].allocated_size)
|
|
|
|
_TIFFfree(tif->tif_fieldscompat[i].fields);
|
|
|
|
}
|
|
|
|
_TIFFfree(tif->tif_fieldscompat);
|
|
|
|
tif->tif_nfieldscompat = 0;
|
|
|
|
tif->tif_fieldscompat = NULL;
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
if (_TIFFextender)
|
|
|
|
(*_TIFFextender)(tif);
|
|
|
|
(void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
|
|
|
|
/*
|
|
|
|
* NB: The directory is marked dirty as a result of setting
|
|
|
|
* up the default compression scheme. However, this really
|
|
|
|
* isn't correct -- we want TIFF_DIRTYDIRECT to be set only
|
|
|
|
* if the user does something. We could just do the setup
|
|
|
|
* by hand, but it seems better to use the normal mechanism
|
|
|
|
* (i.e. TIFFSetField).
|
|
|
|
*/
|
|
|
|
tif->tif_flags &= ~TIFF_DIRTYDIRECT;
|
2000-10-16 23:23:36 -04:00
|
|
|
|
2006-03-24 22:09:24 -05:00
|
|
|
/*
|
|
|
|
* As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
|
|
|
|
* we clear the ISTILED flag when setting up a new directory.
|
|
|
|
* Should we also be clearing stuff like INSUBIFD?
|
|
|
|
*/
|
|
|
|
tif->tif_flags &= ~TIFF_ISTILED;
|
2000-10-16 23:23:36 -04:00
|
|
|
|
1999-07-27 17:50:26 -04:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-06-12 09:07:32 -04:00
|
|
|
TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2006-03-24 22:09:24 -05:00
|
|
|
static const char module[] = "TIFFAdvanceDirectory";
|
|
|
|
if (isMapped(tif))
|
|
|
|
{
|
2007-06-12 09:07:32 -04:00
|
|
|
uint64 poff=*nextdir;
|
2007-03-17 00:41:28 -04:00
|
|
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
2006-03-24 22:09:24 -05:00
|
|
|
{
|
2007-06-27 12:09:58 -04:00
|
|
|
tmsize_t poffa,poffb,poffc,poffd;
|
2007-03-17 00:41:28 -04:00
|
|
|
uint16 dircount;
|
|
|
|
uint32 nextdir32;
|
2007-06-27 12:09:58 -04:00
|
|
|
poffa=(tmsize_t)poff;
|
|
|
|
poffb=poffa+sizeof(uint16);
|
|
|
|
if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size))
|
2007-03-17 00:41:28 -04:00
|
|
|
{
|
2007-06-27 12:09:58 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
|
2013-09-12 22:34:50 -04:00
|
|
|
*nextdir=0;
|
2007-06-27 12:09:58 -04:00
|
|
|
return(0);
|
2007-03-17 00:41:28 -04:00
|
|
|
}
|
2007-06-27 12:09:58 -04:00
|
|
|
_TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16));
|
|
|
|
if (tif->tif_flags&TIFF_SWAB)
|
2007-03-17 00:41:28 -04:00
|
|
|
TIFFSwabShort(&dircount);
|
2007-06-27 12:09:58 -04:00
|
|
|
poffc=poffb+dircount*12;
|
|
|
|
poffd=poffc+sizeof(uint32);
|
|
|
|
if ((poffc<poffb)||(poffc<dircount*12)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint32))||(poffd>tif->tif_size))
|
2007-03-17 00:41:28 -04:00
|
|
|
{
|
2007-06-27 12:09:58 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link");
|
|
|
|
return(0);
|
2007-03-17 00:41:28 -04:00
|
|
|
}
|
2007-06-27 12:09:58 -04:00
|
|
|
if (off!=NULL)
|
|
|
|
*off=(uint64)poffc;
|
|
|
|
_TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32));
|
|
|
|
if (tif->tif_flags&TIFF_SWAB)
|
2007-03-17 00:41:28 -04:00
|
|
|
TIFFSwabLong(&nextdir32);
|
|
|
|
*nextdir=nextdir32;
|
2006-03-24 22:09:24 -05:00
|
|
|
}
|
2007-03-17 00:41:28 -04:00
|
|
|
else
|
2006-03-24 22:09:24 -05:00
|
|
|
{
|
2007-06-27 12:09:58 -04:00
|
|
|
tmsize_t poffa,poffb,poffc,poffd;
|
2007-06-12 09:07:32 -04:00
|
|
|
uint64 dircount64;
|
2007-03-17 00:41:28 -04:00
|
|
|
uint16 dircount16;
|
2007-06-27 12:09:58 -04:00
|
|
|
poffa=(tmsize_t)poff;
|
|
|
|
poffb=poffa+sizeof(uint64);
|
|
|
|
if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint64))||(poffb>tif->tif_size))
|
2007-03-17 00:41:28 -04:00
|
|
|
{
|
2007-06-27 12:09:58 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
|
|
|
|
return(0);
|
2007-03-17 00:41:28 -04:00
|
|
|
}
|
2007-06-27 12:09:58 -04:00
|
|
|
_TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64));
|
|
|
|
if (tif->tif_flags&TIFF_SWAB)
|
2007-03-17 00:41:28 -04:00
|
|
|
TIFFSwabLong8(&dircount64);
|
|
|
|
if (dircount64>0xFFFF)
|
|
|
|
{
|
2007-06-27 12:09:58 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata,module,"Sanity check on directory count failed");
|
2007-03-17 00:41:28 -04:00
|
|
|
return(0);
|
|
|
|
}
|
2007-06-27 12:09:58 -04:00
|
|
|
dircount16=(uint16)dircount64;
|
|
|
|
poffc=poffb+dircount16*20;
|
|
|
|
poffd=poffc+sizeof(uint64);
|
|
|
|
if ((poffc<poffb)||(poffc<dircount16*20)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint64))||(poffd>tif->tif_size))
|
2007-03-17 00:41:28 -04:00
|
|
|
{
|
2007-06-27 12:09:58 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link");
|
|
|
|
return(0);
|
2007-03-17 00:41:28 -04:00
|
|
|
}
|
2007-06-27 12:09:58 -04:00
|
|
|
if (off!=NULL)
|
|
|
|
*off=(uint64)poffc;
|
|
|
|
_TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64));
|
|
|
|
if (tif->tif_flags&TIFF_SWAB)
|
2007-03-17 00:41:28 -04:00
|
|
|
TIFFSwabLong8(nextdir);
|
2006-03-24 22:09:24 -05:00
|
|
|
}
|
2007-06-27 12:09:58 -04:00
|
|
|
return(1);
|
2006-03-24 22:09:24 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-17 00:41:28 -04:00
|
|
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
|
|
|
{
|
|
|
|
uint16 dircount;
|
|
|
|
uint32 nextdir32;
|
|
|
|
if (!SeekOK(tif, *nextdir) ||
|
|
|
|
!ReadOK(tif, &dircount, sizeof (uint16))) {
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
|
|
|
|
tif->tif_name);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (tif->tif_flags & TIFF_SWAB)
|
|
|
|
TIFFSwabShort(&dircount);
|
|
|
|
if (off != NULL)
|
|
|
|
*off = TIFFSeekFile(tif,
|
2007-03-24 07:48:17 -04:00
|
|
|
dircount*12, SEEK_CUR);
|
2007-03-17 00:41:28 -04:00
|
|
|
else
|
|
|
|
(void) TIFFSeekFile(tif,
|
2007-03-24 07:48:17 -04:00
|
|
|
dircount*12, SEEK_CUR);
|
2007-03-17 00:41:28 -04:00
|
|
|
if (!ReadOK(tif, &nextdir32, sizeof (uint32))) {
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
|
|
|
|
tif->tif_name);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (tif->tif_flags & TIFF_SWAB)
|
|
|
|
TIFFSwabLong(&nextdir32);
|
|
|
|
*nextdir=nextdir32;
|
2006-03-24 22:09:24 -05:00
|
|
|
}
|
|
|
|
else
|
2007-03-17 00:41:28 -04:00
|
|
|
{
|
2007-06-12 09:07:32 -04:00
|
|
|
uint64 dircount64;
|
2007-03-17 00:41:28 -04:00
|
|
|
uint16 dircount16;
|
|
|
|
if (!SeekOK(tif, *nextdir) ||
|
2007-06-12 09:07:32 -04:00
|
|
|
!ReadOK(tif, &dircount64, sizeof (uint64))) {
|
2007-03-17 00:41:28 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
|
|
|
|
tif->tif_name);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (tif->tif_flags & TIFF_SWAB)
|
|
|
|
TIFFSwabLong8(&dircount64);
|
|
|
|
if (dircount64>0xFFFF)
|
|
|
|
{
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count");
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
dircount16 = (uint16)dircount64;
|
|
|
|
if (off != NULL)
|
|
|
|
*off = TIFFSeekFile(tif,
|
2007-03-24 07:48:17 -04:00
|
|
|
dircount16*20, SEEK_CUR);
|
2007-03-17 00:41:28 -04:00
|
|
|
else
|
|
|
|
(void) TIFFSeekFile(tif,
|
2007-03-24 07:48:17 -04:00
|
|
|
dircount16*20, SEEK_CUR);
|
2007-06-12 09:07:32 -04:00
|
|
|
if (!ReadOK(tif, nextdir, sizeof (uint64))) {
|
2015-05-31 16:57:56 -04:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"%s: Error fetching directory link",
|
2007-03-17 00:41:28 -04:00
|
|
|
tif->tif_name);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (tif->tif_flags & TIFF_SWAB)
|
|
|
|
TIFFSwabLong8(nextdir);
|
2006-03-24 22:09:24 -05:00
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Count the number of directories in a file.
|
|
|
|
*/
|
2007-04-04 00:16:07 -04:00
|
|
|
uint16
|
1999-07-27 17:50:26 -04:00
|
|
|
TIFFNumberOfDirectories(TIFF* tif)
|
|
|
|
{
|
2013-10-21 14:23:48 -04:00
|
|
|
static const char module[] = "TIFFNumberOfDirectories";
|
2007-06-12 09:07:32 -04:00
|
|
|
uint64 nextdir;
|
2007-04-04 00:16:07 -04:00
|
|
|
uint16 n;
|
2007-03-17 00:41:28 -04:00
|
|
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
|
|
|
nextdir = tif->tif_header.classic.tiff_diroff;
|
|
|
|
else
|
|
|
|
nextdir = tif->tif_header.big.tiff_diroff;
|
|
|
|
n = 0;
|
|
|
|
while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
|
2013-10-21 14:23:48 -04:00
|
|
|
{
|
2015-05-31 19:11:43 -04:00
|
|
|
if (n != 65535) {
|
|
|
|
++n;
|
|
|
|
}
|
|
|
|
else
|
2013-10-21 14:23:48 -04:00
|
|
|
{
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
2015-05-31 16:57:56 -04:00
|
|
|
"Directory count exceeded 65535 limit,"
|
|
|
|
" giving up on counting.");
|
2013-10-21 14:23:48 -04:00
|
|
|
return (65535);
|
|
|
|
}
|
|
|
|
}
|
2007-03-17 00:41:28 -04:00
|
|
|
return (n);
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the n-th directory as the current directory.
|
|
|
|
* NB: Directories are numbered starting at 0.
|
|
|
|
*/
|
|
|
|
int
|
2007-04-04 00:16:07 -04:00
|
|
|
TIFFSetDirectory(TIFF* tif, uint16 dirn)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
2007-06-12 09:07:32 -04:00
|
|
|
uint64 nextdir;
|
2007-04-04 00:16:07 -04:00
|
|
|
uint16 n;
|
1999-07-27 17:50:26 -04:00
|
|
|
|
2007-03-17 00:41:28 -04:00
|
|
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
|
|
|
nextdir = tif->tif_header.classic.tiff_diroff;
|
|
|
|
else
|
|
|
|
nextdir = tif->tif_header.big.tiff_diroff;
|
1999-07-27 17:50:26 -04:00
|
|
|
for (n = dirn; n > 0 && nextdir != 0; n--)
|
|
|
|
if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
|
|
|
|
return (0);
|
|
|
|
tif->tif_nextdiroff = nextdir;
|
|
|
|
/*
|
|
|
|
* Set curdir to the actual directory index. The
|
|
|
|
* -1 is because TIFFReadDirectory will increment
|
|
|
|
* tif_curdir after successfully reading the directory.
|
|
|
|
*/
|
|
|
|
tif->tif_curdir = (dirn - n) - 1;
|
2003-09-25 04:36:21 -04:00
|
|
|
/*
|
2004-07-03 06:26:55 -04:00
|
|
|
* Reset tif_dirnumber counter and start new list of seen directories.
|
|
|
|
* We need this to prevent IFD loops.
|
2003-09-25 04:36:21 -04:00
|
|
|
*/
|
|
|
|
tif->tif_dirnumber = 0;
|
1999-07-27 17:50:26 -04:00
|
|
|
return (TIFFReadDirectory(tif));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the current directory to be the directory
|
|
|
|
* located at the specified file offset. This interface
|
|
|
|
* is used mainly to access directories linked with
|
|
|
|
* the SubIFD tag (e.g. thumbnail images).
|
|
|
|
*/
|
|
|
|
int
|
2007-06-12 09:07:32 -04:00
|
|
|
TIFFSetSubDirectory(TIFF* tif, uint64 diroff)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
|
|
|
tif->tif_nextdiroff = diroff;
|
2003-09-25 04:36:21 -04:00
|
|
|
/*
|
2004-07-03 06:26:55 -04:00
|
|
|
* Reset tif_dirnumber counter and start new list of seen directories.
|
|
|
|
* We need this to prevent IFD loops.
|
2003-09-25 04:36:21 -04:00
|
|
|
*/
|
|
|
|
tif->tif_dirnumber = 0;
|
1999-07-27 17:50:26 -04:00
|
|
|
return (TIFFReadDirectory(tif));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return file offset of the current directory.
|
|
|
|
*/
|
2007-06-26 08:31:25 -04:00
|
|
|
uint64
|
1999-07-27 17:50:26 -04:00
|
|
|
TIFFCurrentDirOffset(TIFF* tif)
|
|
|
|
{
|
|
|
|
return (tif->tif_diroff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return an indication of whether or not we are
|
|
|
|
* at the last directory in the file.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
TIFFLastDirectory(TIFF* tif)
|
|
|
|
{
|
|
|
|
return (tif->tif_nextdiroff == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Unlink the specified directory from the directory chain.
|
|
|
|
*/
|
|
|
|
int
|
2007-04-04 00:16:07 -04:00
|
|
|
TIFFUnlinkDirectory(TIFF* tif, uint16 dirn)
|
1999-07-27 17:50:26 -04:00
|
|
|
{
|
|
|
|
static const char module[] = "TIFFUnlinkDirectory";
|
2007-06-12 09:07:32 -04:00
|
|
|
uint64 nextdir;
|
|
|
|
uint64 off;
|
2007-04-04 00:16:07 -04:00
|
|
|
uint16 n;
|
1999-07-27 17:50:26 -04:00
|
|
|
|
|
|
|
if (tif->tif_mode == O_RDONLY) {
|
2005-12-21 10:55:49 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module,
|
|
|
|
"Can not unlink directory in read-only file");
|
1999-07-27 17:50:26 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Go to the directory before the one we want
|
|
|
|
* to unlink and nab the offset of the link
|
|
|
|
* field we'll need to patch.
|
|
|
|
*/
|
2007-03-17 00:41:28 -04:00
|
|
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
2007-06-22 21:32:31 -04:00
|
|
|
{
|
2007-03-17 00:41:28 -04:00
|
|
|
nextdir = tif->tif_header.classic.tiff_diroff;
|
2007-06-22 21:32:31 -04:00
|
|
|
off = 4;
|
|
|
|
}
|
2007-03-17 00:41:28 -04:00
|
|
|
else
|
2007-06-22 21:32:31 -04:00
|
|
|
{
|
2007-03-17 00:41:28 -04:00
|
|
|
nextdir = tif->tif_header.big.tiff_diroff;
|
2007-06-22 21:32:31 -04:00
|
|
|
off = 8;
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
for (n = dirn-1; n > 0; n--) {
|
|
|
|
if (nextdir == 0) {
|
2005-12-21 07:23:13 -05:00
|
|
|
TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn);
|
1999-07-27 17:50:26 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (!TIFFAdvanceDirectory(tif, &nextdir, &off))
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Advance to the directory to be unlinked and fetch
|
|
|
|
* the offset of the directory that follows.
|
|
|
|
*/
|
|
|
|
if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
|
|
|
|
return (0);
|
|
|
|
/*
|
|
|
|
* Go back and patch the link field of the preceding
|
|
|
|
* directory to point to the offset of the directory
|
|
|
|
* that follows.
|
|
|
|
*/
|
|
|
|
(void) TIFFSeekFile(tif, off, SEEK_SET);
|
2007-06-22 21:32:31 -04:00
|
|
|
if (!(tif->tif_flags&TIFF_BIGTIFF))
|
|
|
|
{
|
|
|
|
uint32 nextdir32;
|
|
|
|
nextdir32=(uint32)nextdir;
|
|
|
|
assert((uint64)nextdir32==nextdir);
|
|
|
|
if (tif->tif_flags & TIFF_SWAB)
|
|
|
|
TIFFSwabLong(&nextdir32);
|
|
|
|
if (!WriteOK(tif, &nextdir32, sizeof (uint32))) {
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (tif->tif_flags & TIFF_SWAB)
|
|
|
|
TIFFSwabLong8(&nextdir);
|
|
|
|
if (!WriteOK(tif, &nextdir, sizeof (uint64))) {
|
|
|
|
TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
|
|
|
|
return (0);
|
|
|
|
}
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Leave directory state setup safely. We don't have
|
|
|
|
* facilities for doing inserting and removing directories,
|
|
|
|
* so it's safest to just invalidate everything. This
|
|
|
|
* means that the caller can only append to the directory
|
|
|
|
* chain.
|
|
|
|
*/
|
|
|
|
(*tif->tif_cleanup)(tif);
|
|
|
|
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
|
|
|
|
_TIFFfree(tif->tif_rawdata);
|
|
|
|
tif->tif_rawdata = NULL;
|
|
|
|
tif->tif_rawcc = 0;
|
2010-04-02 15:26:22 -04:00
|
|
|
tif->tif_rawdataoff = 0;
|
|
|
|
tif->tif_rawdataloaded = 0;
|
1999-07-27 17:50:26 -04:00
|
|
|
}
|
2007-11-23 16:14:43 -05:00
|
|
|
tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE|TIFF_BUF4WRITE);
|
1999-07-27 17:50:26 -04:00
|
|
|
TIFFFreeDirectory(tif);
|
|
|
|
TIFFDefaultDirectory(tif);
|
|
|
|
tif->tif_diroff = 0; /* force link on next write */
|
|
|
|
tif->tif_nextdiroff = 0; /* next write must be at end */
|
|
|
|
tif->tif_curoff = 0;
|
|
|
|
tif->tif_row = (uint32) -1;
|
2007-03-30 21:04:52 -04:00
|
|
|
tif->tif_curstrip = (uint32) -1;
|
1999-07-27 17:50:26 -04:00
|
|
|
return (1);
|
|
|
|
}
|
1999-09-08 08:21:13 -04:00
|
|
|
|
2004-09-14 02:50:22 -04:00
|
|
|
/* vim: set ts=8 sts=8 sw=8 noet: */
|
2010-03-10 13:56:48 -05:00
|
|
|
/*
|
|
|
|
* Local Variables:
|
|
|
|
* mode: c
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* fill-column: 78
|
|
|
|
* End:
|
|
|
|
*/
|