]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/osdmaptool: fix possible segfaults when there are down osds 52203/head
authorMykola Golub <mykola.golub@clyso.com>
Wed, 29 Sep 2021 07:30:56 +0000 (10:30 +0300)
committerMykola Golub <mykola.golub@clyso.com>
Tue, 27 Jun 2023 08:02:16 +0000 (11:02 +0300)
Signed-off-by: Mykola Golub <mykola.golub@clyso.com>
(cherry picked from commit 3cc453705f4b16a0f232c62b32848929b3be8aac)

src/tools/osdmaptool.cc

index 9bbe40f4d169fbd297134df6d56813cdf6d79216..8d1a38f4b36ab928c62c6206f6c30bc7a289bbd5 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]++;