Fixed problem in TIFFReadDirectory() in the code, responsible for tag data type

checking.
This commit is contained in:
Andrey Kiselev 2004-08-20 14:40:10 +00:00
parent 8b8023bb51
commit d0a81ad681

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirread.c,v 1.30 2004-04-29 07:42:33 dron Exp $ */ /* $Id: tif_dirread.c,v 1.31 2004-08-20 14:40:10 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -272,8 +272,9 @@ TIFFReadDirectory(TIFF* tif)
tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) { tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) {
TIFFWarning(module, TIFFWarning(module,
"%.1000s: unknown field with tag %d (0x%x) encountered", "%.1000s: unknown field with tag %d (0x%x) and type %d encountered",
tif->tif_name, dp->tdir_tag, dp->tdir_tag); tif->tif_name, dp->tdir_tag, dp->tdir_tag,
dp->tdir_type);
TIFFMergeFieldInfo( tif, TIFFMergeFieldInfo( tif,
_TIFFCreateAnonFieldInfo( tif, _TIFFCreateAnonFieldInfo( tif,
@ -296,17 +297,18 @@ TIFFReadDirectory(TIFF* tif)
/* /*
* Check data type. * Check data type.
*/ */
fip = tif->tif_fieldinfo[fix]; fip = tif->tif_fieldinfo[fix++];
while (dp->tdir_type != (u_short) fip->field_type) { while (dp->tdir_type != (u_short) fip->field_type
&& fix < tif->tif_nfields) {
if (fip->field_type == TIFF_ANY) /* wildcard */ if (fip->field_type == TIFF_ANY) /* wildcard */
break; break;
fip++, fix++; fip = tif->tif_fieldinfo[fix++];
if (fix == tif->tif_nfields || if (fix >= tif->tif_nfields ||
fip->field_tag != dp->tdir_tag) { fip->field_tag != dp->tdir_tag) {
TIFFWarning(module, TIFFWarning(module,
"%.1000s: wrong data type %d for \"%s\"; tag ignored", "%.1000s: wrong data type %d for \"%s\"; tag ignored",
tif->tif_name, dp->tdir_type, tif->tif_name, dp->tdir_type,
fip[-1].field_name); tif->tif_fieldinfo[fix-1]->field_name);
goto ignore; goto ignore;
} }
} }