This is an archive of the discontinued LLVM Phabricator instance.

YAMLIO: Fix serialization of strings with embedded nuls
ClosedPublic

Authored by labath on Apr 10 2019, 4:53 AM.

Details

Summary

A bug/typo in Output::scalarString caused us to round-trip a StringRef
through a const char *. This meant that any strings with embedded nuls
were unintentionally cut short at the first such character. (It also
could have caused accidental buffer overruns, but it seems that all
StringRefs coming into this functions were formed from null-terminated
strings.)

This patch fixes the bug and adds an appropriate test.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Apr 10 2019, 4:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2019, 4:53 AM
Herald added a subscriber: kristina. · View Herald Transcript
sammccall accepted this revision.Apr 10 2019, 5:13 AM

Ouch, thanks!

This revision is now accepted and ready to land.Apr 10 2019, 5:13 AM
This revision was automatically updated to reflect the committed changes.