cephtool: gui: handle bad input in view_node

Signed-off-by: Colin McCabe <colinm@hq.newdream.net>
This commit is contained in:
Colin Patrick McCabe 2010-10-28 15:34:00 -07:00
parent 89273b7fe0
commit 329fbc240d

View File

@ -1317,16 +1317,17 @@ void GuiMonitor::handle_view_node_response(int response)
switch (selected_type) {
case OSD_NODE: {
int id;
unsigned int id;
try {
id = boost::lexical_cast<int>(id_entry);
id = boost::lexical_cast<unsigned int>(id_entry);
}
catch (const boost::bad_lexical_cast &) {
dialog_error("Node ID must be a number.", Gtk::MESSAGE_ERROR);
return;
}
if (id >= g.osdmap.get_max_osd()) {
unsigned int max_osd = g.osdmap.get_max_osd();
if (id >= max_osd) {
dialog_error("OSD does not exist.", Gtk::MESSAGE_ERROR);
return;
}
@ -1356,7 +1357,6 @@ void GuiMonitor::handle_view_node_response(int response)
dialog_error("Node ID must be a number.", Gtk::MESSAGE_ERROR);
return;
}
if (id >= g.pgmap.pg_stat.size()) {
dialog_error("PG does not exist.", Gtk::MESSAGE_ERROR);
return;