]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Resolve unhandled exception in 45547/head
authorNikhil Kshirsagar <nkshirsagar@gmail.com>
Tue, 22 Mar 2022 05:04:23 +0000 (10:34 +0530)
committerNikhil Kshirsagar <nkshirsagar@gmail.com>
Thu, 31 Mar 2022 03:49:46 +0000 (09:19 +0530)
__generate_command_map()

If improper json data is passed to rados, it can
end up crashing the mon. This fix will catch the
exception if thrown by __generate_command_map()
and avoid the mon getting terminated due to an
uncaught exception.

Fixes: https://tracker.ceph.com/issues/54558
Signed-off-by: Nikhil Kshirsagar <nkshirsagar@gmail.com>
src/mon/Monitor.cc

index d1e54d36c7bfa2a59099160a2cb749252f706f16..ca4ccb9fecf3f087a4d6c1614c5d3e17917a9db8 100644 (file)
@@ -3424,7 +3424,15 @@ void Monitor::handle_command(MonOpRequestRef op)
 
   // validate user's permissions for requested command
   map<string,string> param_str_map;
-  _generate_command_map(cmdmap, param_str_map);
+
+  // Catch bad_cmd_get exception if _generate_command_map() throws it
+  try {
+    _generate_command_map(cmdmap, param_str_map);
+  }
+  catch(bad_cmd_get& e) {
+    reply_command(op, -EINVAL, e.what(), 0);
+  }
+
   if (!_allowed_command(session, service, prefix, cmdmap,
                         param_str_map, mon_cmd)) {
     dout(1) << __func__ << " access denied" << dendl;