From 329fbc240d62b8aabc36848a945a752ea385a09d Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 28 Oct 2010 15:34:00 -0700 Subject: [PATCH] cephtool: gui: handle bad input in view_node Signed-off-by: Colin McCabe --- src/tools/gui.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/gui.cc b/src/tools/gui.cc index 9872b94cd0e..c0fdc5a8d57 100644 --- a/src/tools/gui.cc +++ b/src/tools/gui.cc @@ -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(id_entry); + id = boost::lexical_cast(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;