diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 3e0062228f6..03de4adb125 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -995,7 +995,12 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) ss << "max_osd = " << osdmap.get_max_osd() << " in epoch " << osdmap.get_epoch(); r = 0; } - else if (m->cmd[1] == "injectargs" && m->cmd.size() == 4) { + else if (m->cmd[1] == "injectargs") { + if (m->cmd.size() != 4) { + r = -EINVAL; + ss << "usage: osd injectargs "; + goto out; + } if (m->cmd[2] == "*") { for (int i=0; icmd[1] == "tell") { + if (m->cmd.size() < 4) { + r = -EINVAL; + ss << "usage: osd tell "; + goto out; + } m->cmd.erase(m->cmd.begin()); //take out first two args; don't need them m->cmd.erase(m->cmd.begin()); if (m->cmd[0] == "*") { @@ -1039,7 +1049,12 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) } else ss << "specify osd number or *"; } } - else if ((m->cmd[1] == "scrub" || m->cmd[1] == "repair") && m->cmd.size() > 2) { + else if ((m->cmd[1] == "scrub" || m->cmd[1] == "repair")) { + if (m->cmd.size() <= 2) { + r = -EINVAL; + ss << "usage: osd [scrub|repair] "; + goto out; + } if (m->cmd[2] == "*") { ss << "osds "; int c = 0; @@ -1079,6 +1094,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) r = 0; } } + out: if (r != -1) { string rs; getline(ss, rs);