Commit
525623b has introduced a regression that makes Ceph clients of
versions prior to Nautilus to receive invalid unicode characters in the
commands list JSON sent by the monitors.
The unicode characters are caused by memory corruption in a dangling
pointer stored by a std::string_view. The dangling pointer belonged to
an std::string object that was already destructed when the
std::string_view is used.
The fix in this PR makes the std::string object to live enough time for
the std::string_view to be used safely.
Signed-off-by: Ricardo Dias <rdias@suse.com>
f->open_object_section(string(desckv["name"]).c_str());
// Compatibility for pre-nautilus clients that don't know about CephBool
+ std::string val;
if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
auto i = desckv.find("type");
if (i != desckv.end() && i->second == "CephBool") {
// of a 'true'/'false' value
std::ostringstream oss;
oss << std::string("--") << desckv["name"];
- std::string val = oss.str();
+ val = oss.str();
std::replace(val.begin(), val.end(), '_', '-');
desckv["type"] = "CephChoices";