diff options
author | Loic Dachary <loic@dachary.org> | 2014-02-10 23:42:38 +0100 |
---|---|---|
committer | Loic Dachary <loic@dachary.org> | 2014-02-11 09:21:35 +0100 |
commit | 165e76d4d03ffcc490fd3c2ba60fb37372990d0a (patch) | |
tree | 666e94f5331697545bc2ad5527bab44c2e53575c /src/osdc | |
parent | Merge remote-tracking branch 'gh/wip-7329' into next (diff) | |
download | ceph-165e76d4d03ffcc490fd3c2ba60fb37372990d0a.tar.xz ceph-165e76d4d03ffcc490fd3c2ba60fb37372990d0a.zip |
common: admin socket fallback to json-pretty format
If the format argument to a command sent to the admin socket is not
among the supported formats ( json, json-pretty, xml, xml-pretty ) the
new_formatter function will return null and the AdminSocketHook::call
function must fall back to a sensible default.
The CephContextHook::call and HelpHook::call failed to do that and a
malformed format argument would cause the mon to crash. A check is added
to each of them and fallback to json-pretty if the format is not
recognized.
To further protect AdminSocketHook::call implementations from similar
problems the format argument is checked immediately after accepting the
command in AdminSocket::do_accept and replaced with json-pretty if it is
not known.
A test case is added for both CephContextHook::call and HelpHook::call
to demonstrate the problem exists and is fixed by the patch.
Three other instances of unsafe calls to new_formatter were found and
a fallback to json-pretty was added. All other calls have been audited
and appear to be safe.
http://tracker.ceph.com/issues/7378 fixes #7378
Backport: emperor, dumpling
Signed-off-by: Loic Dachary <loic@dachary.org>
Diffstat (limited to 'src/osdc')
-rw-r--r-- | src/osdc/Objecter.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 3da9be9c1c0..ce48fba0500 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -2507,6 +2507,8 @@ bool Objecter::RequestStateHook::call(std::string command, cmdmap_t& cmdmap, std::string format, bufferlist& out) { Formatter *f = new_formatter(format); + if (!f) + f = new_formatter("json-pretty"); m_objecter->client_lock.Lock(); m_objecter->dump_requests(f); m_objecter->client_lock.Unlock(); |