Skip to content

Commit c45c9c6

Browse files
committed
fix(tiff): more care ignoring XMP tags that should not be used (AcademySoftwareFoundation#5162)
Guard against corrupt XMP blocks with TIFF related names: if the XMP item starts with "tiff:", just ignore it if it's not one of the few TIFF-related XMP items we recognize of if it's marked redundant, and don't *replace* a TIFF related item that already had a value in the spec. Fixes AcademySoftwareFoundation#5157 Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent c8a85bf commit c45c9c6

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

src/libOpenImageIO/xmp.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,14 @@ add_attrib(ImageSpec& spec, string_view xmlname, string_view xmlvalue,
294294

295295
// See if it's in the xmp table, which will tell us something about the
296296
// proper type (everything in the xml itself just looks like a string).
297-
if (const XMPtag* xt = xmp_tagmap_ref().find(xmlname)) {
298-
if (!xt->oiioname || !xt->oiioname[0])
297+
const XMPtag* xmptagptr = xmp_tagmap_ref().find(xmlname);
298+
if (xmptagptr) {
299+
if (!xmptagptr->oiioname || !xmptagptr->oiioname[0])
299300
return 0; // ignore it purposefully
300301
// Found
301-
oiioname = xt->oiioname;
302-
oiiotype = xt->oiiotype;
303-
special = xt->special;
302+
oiioname = xmptagptr->oiioname;
303+
oiiotype = xmptagptr->oiiotype;
304+
special = xmptagptr->special;
304305
}
305306

306307
// Also try looking it up to see if it's a known exif tag.
@@ -325,6 +326,21 @@ add_attrib(ImageSpec& spec, string_view xmlname, string_view xmlvalue,
325326
return 0; // skip
326327
}
327328

329+
if (Strutil::istarts_with(xmlname, "tiff:")) {
330+
if (!xmptagptr) // Ignore any "tiff:" entry not in the table
331+
return 0;
332+
if (special & TiffRedundant) // Ignore ones marked redundant
333+
return 0;
334+
// Ignore any TIFF related ones we already have set in the spec, don't
335+
// let the XMP version overwrite what we gleaned directly from the
336+
// file.
337+
if (spec.find_attribute(oiioname))
338+
return 0;
339+
}
340+
341+
if (special & Suppress)
342+
return 0; // Marked as one to suppress
343+
328344
// Guess the type if unknown
329345
if (oiiotype == TypeUnknown) {
330346
if (Strutil::string_is_int(xmlvalue))

0 commit comments

Comments
 (0)