mgmt,rib: check command length before accessing verb

refs: #2151

Change-Id: I0e67fd4b4df10d842648797ed42771af7c53a938
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index e7ea3e9..491739a 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -200,7 +200,16 @@
 RibManager::onLocalhostRequest(const Interest& request)
 {
   const Name& command = request.getName();
-  const Name::Component& verb = command.get(COMMAND_PREFIX.size());
+
+  if (command.size() <= COMMAND_PREFIX.size())
+    {
+      // command is too short to have a verb
+      NFD_LOG_DEBUG("command result: malformed");
+      sendResponse(command, 400, "Malformed command");
+      return;
+    }
+
+  const Name::Component& verb = command.at(COMMAND_PREFIX.size());
 
   UnsignedVerbDispatchTable::const_iterator unsignedVerbProcessor = m_unsignedVerbDispatch.find(verb);