From: Sage Weil Date: Fri, 3 May 2013 23:04:31 +0000 (-0700) Subject: mon: avoid null deref in Monitor::_mon_status() X-Git-Tag: v0.61~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3f0b8ec2d4897fa74e1b7b187614fc6f93a7b248;p=ceph.git mon: avoid null deref in Monitor::_mon_status() mikedawson reports: *** Caught signal (Segmentation fault) ** in thread 7f40ce270700 ceph version 0.60-801-g7ec0151 (7ec01513970b5a977bdbdf60052b6f6e257d267e) 1: /usr/bin/ceph-mon() [0x59d550] 2: (()+0xfbd0) [0x7f40d3e38bd0] 3: (operator<<(std::ostream&, entity_name_t const&)+0x16) [0x4d7c46] 4: (operator<<(std::ostream&, entity_inst_t const&)+0x1b) [0x4d837b] 5: (Monitor::_mon_status(std::ostream&)+0x2ce) [0x4d284e] 6: (Monitor::do_admin_command(std::string, std::string, std::ostream&)+0x4f) [0x4d652f] 7: (AdminHook::call(std::string, std::string, ceph::buffer::list&)+0x68) [0x4efa38] 8: (AdminSocket::do_accept()+0x451) [0x64ab81] 9: (AdminSocket::entry()+0x398) [0x64c528] 10: (()+0x7f8e) [0x7f40d3e30f8e] 11: (clone()+0x6d) [0x7f40d237ae1d] Signed-off-by: Sage Weil Reviewed-by: Greg Farnum --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index b9afa4265d8f..56cd291cd24a 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2287,8 +2287,14 @@ void Monitor::_mon_status(ostream& ss) jf.close_section(); if (is_synchronizing()) { - jf.dump_stream("sync_leader") << sync_leader->entity; - jf.dump_stream("sync_provider") << sync_provider->entity; + if (sync_leader) + jf.dump_stream("sync_leader") << sync_leader->entity; + else + jf.dump_string("sync_leader", ""); + if (sync_provider) + jf.dump_stream("sync_provider") << sync_provider->entity; + else + jf.dump_string("sync_provider", ""); } jf.open_object_section("monmap");