Skip to content

Commit c3fbed1

Browse files
authored
fix(tiff): more care ignoring XMP tags that should not be used (#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 #5157 Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 670c261 commit c3fbed1

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
@@ -299,13 +299,14 @@ add_attrib(ImageSpec& spec, string_view xmlname, string_view xmlvalue,
299299

300300
// See if it's in the xmp table, which will tell us something about the
301301
// proper type (everything in the xml itself just looks like a string).
302-
if (const XMPtag* xt = xmp_tagmap_ref().find(xmlname)) {
303-
if (!xt->oiioname || !xt->oiioname[0])
302+
const XMPtag* xmptagptr = xmp_tagmap_ref().find(xmlname);
303+
if (xmptagptr) {
304+
if (!xmptagptr->oiioname || !xmptagptr->oiioname[0])
304305
return 0; // ignore it purposefully
305306
// Found
306-
oiioname = xt->oiioname;
307-
oiiotype = xt->oiiotype;
308-
special = xt->special;
307+
oiioname = xmptagptr->oiioname;
308+
oiiotype = xmptagptr->oiiotype;
309+
special = xmptagptr->special;
309310
}
310311

311312
// Also try looking it up to see if it's a known exif tag.
@@ -330,6 +331,21 @@ add_attrib(ImageSpec& spec, string_view xmlname, string_view xmlvalue,
330331
return 0; // skip
331332
}
332333

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

0 commit comments

Comments
 (0)