From 43ef8c10ba55f4c42999cdc34492eb5391d49b68 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 27 Nov 2012 20:47:31 -0800 Subject: [PATCH] mon: do not crash on invalid 'mon tell N ...' target Fixes: #3545 Signed-off-by: Sage Weil --- src/mon/MonmapMonitor.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 24624bbc268d8..e18c4a92d807d 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -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)); -- 2.39.5