]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonMap.h: fix potential segfault, add assert()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 11 Jun 2015 18:01:26 +0000 (20:01 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 17 Jul 2015 08:50:44 +0000 (10:50 +0200)
Fix for:

CID 1297860 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
1. Condition this->mon_addr.count(n), taking true branch
2. negative_return_fn: Function this->get_rank(n) returns a
   negative number. [show details]
3. var_assign: Assigning: signed variable m = get_rank.
4. negative_returns: m is passed to a parameter that cannot be
   negative.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/mon/MonMap.h

index ae81b073ca4727d0f519ff92bfe5fc7790b22813..390d88a7ca2e15a1a5aad911fda166b95a23070b 100644 (file)
@@ -159,6 +159,7 @@ class MonMap {
   entity_inst_t get_inst(const string& n) {
     assert(mon_addr.count(n));
     int m = get_rank(n);
+    assert(m >= 0); // vector can't take negative indicies
     entity_inst_t i;
     i.addr = rank_addr[m];
     i.name = entity_name_t::MON(m);