mirror of
https://gitlab.com/libtiff/libtiff.git
synced 2026-01-18 21:51:18 +01:00
No longer emit warnings about unknown tags by default, and add TIFFOpenOptionsSetWarnAboutUnknownTags() for explicit control
This commit is contained in:
@@ -24,6 +24,8 @@ Synopsis
|
||||
|
||||
.. c:function:: void TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions* opts, TIFFErrorHandlerExtR handler, void* warnhandler_user_data)
|
||||
|
||||
.. c:function:: void TIFFOpenOptionsSetWarnAboutUnknownTags(TIFFOpenOptions *opts, int warn_about_unknown_tags)
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
@@ -71,6 +73,11 @@ The *errorhandler_user_data* argument may be NULL.
|
||||
:c:func:`TIFFOpenOptionsSetErrorHandlerExtR` but for the warning handler,
|
||||
which is invoked through :c:func:`TIFFWarningExtR`
|
||||
|
||||
:c:func:`TIFFOpenOptionsSetWarnAboutUnknownTags` sets whether libtiff should
|
||||
emit a warning when encountering a unknown tag. This function has been added in
|
||||
libtiff 4.7.1 and the default value is FALSE (change of behaviour compared to
|
||||
earlier versions).
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ EXPORTS TIFFAccessTagMethods
|
||||
TIFFOpenOptionsSetMaxCumulatedMemAlloc
|
||||
TIFFOpenOptionsSetMaxSingleMemAlloc
|
||||
TIFFOpenOptionsSetErrorHandlerExtR
|
||||
TIFFOpenOptionsSetWarnAboutUnknownTags
|
||||
TIFFOpenOptionsSetWarningHandlerExtR
|
||||
TIFFPrintDirectory
|
||||
TIFFRGBAImageBegin
|
||||
|
||||
@@ -218,3 +218,7 @@ LIBTIFF_4.5 {
|
||||
LIBTIFF_4.6.1 {
|
||||
TIFFOpenOptionsSetMaxCumulatedMemAlloc;
|
||||
} LIBTIFF_4.5;
|
||||
|
||||
LIBTIFF_4.7.1 {
|
||||
TIFFOpenOptionsSetWarnAboutUnknownTags;
|
||||
} LIBTIFF_4.6.1;
|
||||
|
||||
@@ -4403,10 +4403,13 @@ int TIFFReadDirectory(TIFF *tif)
|
||||
TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
|
||||
if (fii == FAILED_FII)
|
||||
{
|
||||
TIFFWarningExtR(tif, module,
|
||||
"Unknown field with tag %" PRIu16 " (0x%" PRIx16
|
||||
") encountered",
|
||||
dp->tdir_tag, dp->tdir_tag);
|
||||
if (tif->tif_warn_about_unknown_tags)
|
||||
{
|
||||
TIFFWarningExtR(tif, module,
|
||||
"Unknown field with tag %" PRIu16
|
||||
" (0x%" PRIx16 ") encountered",
|
||||
dp->tdir_tag, dp->tdir_tag);
|
||||
}
|
||||
/* the following knowingly leaks the
|
||||
anonymous field structure */
|
||||
const TIFFField *fld = _TIFFCreateAnonField(
|
||||
@@ -5344,18 +5347,25 @@ int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff,
|
||||
TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii);
|
||||
if (fii == FAILED_FII)
|
||||
{
|
||||
TIFFWarningExtR(tif, module,
|
||||
"Unknown field with tag %" PRIu16 " (0x%" PRIx16
|
||||
") encountered",
|
||||
dp->tdir_tag, dp->tdir_tag);
|
||||
if (tif->tif_warn_about_unknown_tags)
|
||||
{
|
||||
TIFFWarningExtR(tif, module,
|
||||
"Unknown field with tag %" PRIu16 " (0x%" PRIx16
|
||||
") encountered",
|
||||
dp->tdir_tag, dp->tdir_tag);
|
||||
}
|
||||
const TIFFField *fld = _TIFFCreateAnonField(
|
||||
tif, dp->tdir_tag, (TIFFDataType)dp->tdir_type);
|
||||
if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
|
||||
{
|
||||
TIFFWarningExtR(tif, module,
|
||||
"Registering anonymous field with tag %" PRIu16
|
||||
" (0x%" PRIx16 ") failed",
|
||||
dp->tdir_tag, dp->tdir_tag);
|
||||
if (tif->tif_warn_about_unknown_tags)
|
||||
{
|
||||
TIFFWarningExtR(
|
||||
tif, module,
|
||||
"Registering anonymous field with tag %" PRIu16
|
||||
" (0x%" PRIx16 ") failed",
|
||||
dp->tdir_tag, dp->tdir_tag);
|
||||
}
|
||||
dp->tdir_ignore = TRUE;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -109,6 +109,15 @@ void TIFFOpenOptionsSetMaxCumulatedMemAlloc(TIFFOpenOptions *opts,
|
||||
opts->max_cumulated_mem_alloc = max_cumulated_mem_alloc;
|
||||
}
|
||||
|
||||
/** Whether a warning should be emitted when encoutering a unknown tag.
|
||||
* Default is FALSE since libtiff 4.7.1
|
||||
*/
|
||||
void TIFFOpenOptionsSetWarnAboutUnknownTags(TIFFOpenOptions *opts,
|
||||
int warn_about_unknown_tags)
|
||||
{
|
||||
opts->warn_about_unknown_tags = warn_about_unknown_tags;
|
||||
}
|
||||
|
||||
void TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
|
||||
TIFFErrorHandlerExtR handler,
|
||||
void *errorhandler_user_data)
|
||||
@@ -386,6 +395,7 @@ TIFF *TIFFClientOpenExt(const char *name, const char *mode,
|
||||
tif->tif_warnhandler_user_data = opts->warnhandler_user_data;
|
||||
tif->tif_max_single_mem_alloc = opts->max_single_mem_alloc;
|
||||
tif->tif_max_cumulated_mem_alloc = opts->max_cumulated_mem_alloc;
|
||||
tif->tif_warn_about_unknown_tags = opts->warn_about_unknown_tags;
|
||||
}
|
||||
|
||||
if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc)
|
||||
|
||||
@@ -508,6 +508,9 @@ extern int TIFFReadRGBAImageOriented(TIFF *, uint32_t, uint32_t, uint32_t *,
|
||||
TIFFOpenOptionsSetMaxCumulatedMemAlloc(TIFFOpenOptions *opts,
|
||||
tmsize_t max_cumulated_mem_alloc);
|
||||
extern void
|
||||
TIFFOpenOptionsSetWarnAboutUnknownTags(TIFFOpenOptions *opts,
|
||||
int warn_about_unknown_tags);
|
||||
extern void
|
||||
TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts,
|
||||
TIFFErrorHandlerExtR handler,
|
||||
void *errorhandler_user_data);
|
||||
|
||||
@@ -258,6 +258,7 @@ struct tiff
|
||||
tmsize_t tif_max_single_mem_alloc; /* in bytes. 0 for unlimited */
|
||||
tmsize_t tif_max_cumulated_mem_alloc; /* in bytes. 0 for unlimited */
|
||||
tmsize_t tif_cur_cumulated_mem_alloc; /* in bytes */
|
||||
int tif_warn_about_unknown_tags;
|
||||
};
|
||||
|
||||
struct TIFFOpenOptions
|
||||
@@ -268,6 +269,7 @@ struct TIFFOpenOptions
|
||||
void *warnhandler_user_data; /* may be NULL */
|
||||
tmsize_t max_single_mem_alloc; /* in bytes. 0 for unlimited */
|
||||
tmsize_t max_cumulated_mem_alloc; /* in bytes. 0 for unlimited */
|
||||
int warn_about_unknown_tags;
|
||||
};
|
||||
|
||||
#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
|
||||
|
||||
Reference in New Issue
Block a user