Skip to content

Commit 44ef6ae

Browse files
authored
Strip XMP raw packet before decoding (#2139)
(cherry picked from commit eb49d66)
1 parent d70e575 commit 44ef6ae

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/xmp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,12 @@ namespace Exiv2 {
765765
return 2;
766766
}
767767

768-
XMLValidator::check(xmpPacket.data(), xmpPacket.size());
769-
SXMPMeta meta(xmpPacket.data(), static_cast<XMP_StringLen>(xmpPacket.size()));
768+
// Make sure the unterminated substring is used
769+
size_t len = xmpPacket.size();
770+
while (len > 0 && 0 == xmpPacket[len - 1]) --len;
771+
772+
XMLValidator::check(xmpPacket.data(), len);
773+
SXMPMeta meta(xmpPacket.data(), static_cast<XMP_StringLen>(len));
770774
SXMPIterator iter(meta);
771775
std::string schemaNs, propPath, propValue;
772776
XMP_OptionBits opt = 0;

0 commit comments

Comments
 (0)