Skip to content

Commit 1d28fe6

Browse files
committed
Merge branch 'master' into 'master'
Setting the TIFFFieldInfo field `set_field_type` should consider `field_writecount` not `field_readcount` See merge request libtiff/libtiff!544
2 parents 25bad37 + cee5e99 commit 1d28fe6

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

libtiff/tif_dirinfo.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static const TIFFField exifFields[] = {
374374
{EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL},
375375
{EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL},
376376
{EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL},
377-
/*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance!
377+
/*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance!
378378
* However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values,
379379
* which are not treated within LibTiff!! */
380380
{EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL},
@@ -1197,12 +1197,24 @@ int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldInfo info[], uint32_t n)
11971197
for (i = 0; i < n; i++)
11981198
{
11991199
tp->field_tag = info[i].field_tag;
1200+
if (info[i].field_readcount < TIFF_VARIABLE2 ||
1201+
info[i].field_readcount == 0 ||
1202+
info[i].field_writecount < TIFF_VARIABLE2 ||
1203+
info[i].field_writecount == 0)
1204+
{
1205+
/* The fields (field_readcount) and (field_writecount) may use the
1206+
* values TIFF_VARIABLE (-1), TIFF_SPP (-2), TIFF_VARIABLE2 (-3). */
1207+
TIFFErrorExtR(tif, module,
1208+
"The value of field_readcount and field_writecount "
1209+
"must be greater than or equal to -3 and not zero.");
1210+
return -1;
1211+
}
12001212
tp->field_readcount = info[i].field_readcount;
12011213
tp->field_writecount = info[i].field_writecount;
12021214
tp->field_type = info[i].field_type;
12031215
tp->field_anonymous = 0;
12041216
tp->set_field_type =
1205-
_TIFFSetGetType(info[i].field_type, info[i].field_readcount,
1217+
_TIFFSetGetType(info[i].field_type, info[i].field_writecount,
12061218
info[i].field_passcount);
12071219
tp->get_field_type =
12081220
_TIFFSetGetType(info[i].field_type, info[i].field_readcount,

0 commit comments

Comments
 (0)