diff --git a/ChangeLog b/ChangeLog index 24d5da2f..ac20efab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-05-29 Frank Warmerdam + * libtiff/tif_dir.c: avoid using specific set/get logic to process fields in custom directories, + like EXIF directories. This fixes problems like a tag "320" existing in a custom directory getting + processed as if it were a colormap when it isn't really. Damn the wide variety of argument formulations + to get/set functions for different tags! + * libtiff/tif_dir.c: Ensure that we keep track of when tif_rawdata is a pointer into an mmap()ed file via TIFF_BUFFERMMAP flag. diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c index 7c85f6c3..9b049a2e 100644 --- a/libtiff/tif_dir.c +++ b/libtiff/tif_dir.c @@ -1,4 +1,4 @@ -/* $Id: tif_dir.c,v 1.109 2012-05-24 01:03:37 fwarmerdam Exp $ */ +/* $Id: tif_dir.c,v 1.110 2012-05-30 04:58:13 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -161,8 +161,20 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) int status = 1; uint32 v32, i, v; char* s; + const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); + uint32 standard_tag = tag; - switch (tag) { + /* + * 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 (ie. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } + + switch (standard_tag) { case TIFFTAG_SUBFILETYPE: td->td_subfiletype = (uint32) va_arg(ap, uint32); break; @@ -427,7 +439,6 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) default: { TIFFTagValue *tv; int tv_size, iCustom; - const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); /* * This can happen if multiple images are open with different @@ -799,8 +810,20 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) { TIFFDirectory* td = &tif->tif_dir; int ret_val = 1; + uint32 standard_tag = tag; + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + + /* + * 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 (ie. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } - switch (tag) { + switch (standard_tag) { case TIFFTAG_SUBFILETYPE: *va_arg(ap, uint32*) = td->td_subfiletype; break; @@ -975,8 +998,6 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) break; default: { - const TIFFField* fip = - TIFFFindField(tif, tag, TIFF_ANY); int i; /*