mirror of
https://github.com/ceph/ceph
synced 2025-03-31 16:25:56 +00:00
ceph_argparse: fix CephBool to CephChoices conversion
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>
This commit is contained in:
parent
b021f2cad5
commit
1a1691d20c
@ -93,6 +93,7 @@ dump_cmd_to_json(Formatter *f, uint64_t features, const string& cmd)
|
||||
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") {
|
||||
@ -100,7 +101,7 @@ dump_cmd_to_json(Formatter *f, uint64_t features, const string& cmd)
|
||||
// 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";
|
||||
|
Loading…
Reference in New Issue
Block a user