]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: do not crash on invalid 'mon tell N ...' target
authorSage Weil <sage@inktank.com>
Wed, 28 Nov 2012 04:47:31 +0000 (20:47 -0800)
committerSage Weil <sage@inktank.com>
Wed, 28 Nov 2012 04:51:03 +0000 (20:51 -0800)
Fixes: #3545
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/MonmapMonitor.cc

index 24624bbc268d8cb31d7aaf100dfa568b40a25552..e18c4a92d807dbccfe866e23b49d9bad39df8033 100644 (file)
@@ -257,9 +257,14 @@ bool MonmapMonitor::preprocess_command(MMonCommand *m)
          r = -EINVAL;
          goto out;
        }
-        stringstream ss;
+       if (target >= mon->monmap->size()) {
+         ss << "mon." << target << " does not exist";
+         r = -ENOENT;
+         goto out;
+       }
 
        // send to target, or handle if it's me
+       stringstream ss;
        MMonCommand *newm = new MMonCommand(m->fsid, m->version);
        newm->cmd.insert(newm->cmd.begin(), m->cmd.begin() + 3, m->cmd.end());
        mon->messenger->send_message(newm, mon->monmap->get_inst(target));