]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
tools/osdmaptool: fix possible segfaults when there are down osds
authorMykola Golub <mykola.golub@clyso.com>
Wed, 29 Sep 2021 07:30:56 +0000 (10:30 +0300)
committerMykola Golub <mykola.golub@clyso.com>
Sun, 9 Jan 2022 10:33:27 +0000 (12:33 +0200)
Signed-off-by: Mykola Golub <mykola.golub@clyso.com>
src/tools/osdmaptool.cc

index e8bf48fbbbfd1d4bfaa16436ae5f5aa932813c11..0fae78565a9532a149752a554cc6b2fa607ba6e6 100644 (file)
@@ -684,9 +684,10 @@ skip_upmap:
 
        for (unsigned i=0; i<osds.size(); i++) {
          //cout << " rep " << i << " on " << osds[i] << std::endl;
-         count[osds[i]]++;
+          if (osds[i] != CRUSH_ITEM_NONE)
+            count[osds[i]]++;
        }
-       if (osds.size())
+       if (osds.size() && osds[0] != CRUSH_ITEM_NONE)
          first_count[osds[0]]++;
        if (primary >= 0)
          primary_count[primary]++;