CRITICAL: XMP Toolkit error 4: Invalid UTF-8 data byte
Exporting the file attached to issue #1561 (closed), I see these two CRITICALS printed on the console:
** (file-jpeg:6660): CRITICAL **: 15:04:22.063: XMP Toolkit error 4: Invalid UTF-8 data byte
** (file-jpeg:6660): CRITICAL **: 15:04:22.069: Failed to encode XMP metadata.
The first relevant valgrind message
==6660==
==6660== Conditional jump or move depends on uninitialised value(s)
==6660== at 0x483BC38: strlen (vg_replace_strmem.c:460)
==6660== by 0x5D5F843: printf_positional (in /usr/lib64/libc-2.28.so)
==6660== by 0x5D60795: vfprintf (in /usr/lib64/libc-2.28.so)
==6660== by 0x5E1B7FC: __vsnprintf_chk (in /usr/lib64/libc-2.28.so)
==6660== by 0x59D21CC: g_snprintf (gprintf.c:170)
==6660== by 0x49898E6: gimp_metadata_add_xmp_history (gimpmetadata.c:424)
==6660== by 0x485B8EA: gimp_image_metadata_save_finish (gimpimagemetadata.c:479)
==6660== by 0x406553: run (jpeg.c:573)
==6660== by 0x4883D84: gimp_proc_run (gimp.c:2439)
==6660== by 0x4883D84: gimp_loop (gimp.c:2264)
==6660== by 0x4883D84: gimp_main (gimp.c:671)
==6660== by 0x5D33412: (below main) (in /usr/lib64/libc-2.28.so)
==6660== Uninitialised value was created by a stack allocation
==6660== at 0x49894BD: gimp_metadata_add_xmp_history (gimpmetadata.c:273)
points to libgimpbase/gimpmetadata.c#L418:
where it is possible to see that the NUL terminator written by strftime()
at tzstr[5]
is overwritten and
not copied to tzstr[6]
leaving tzstr
seldom NUL terminated. Adding a tzstr[6] = '\0'
before passing
it to g_snprintf()
avoids printing CRITICALS and saving possibly corrupt metadata.