]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: modify RGWRados::cls_bucket_list_ordered to store dirent key before 51549/head
authorVedansh Bhartia <vedanshbhartia@gmail.com>
Thu, 18 May 2023 07:58:20 +0000 (13:28 +0530)
committerVedansh Bhartia <vedanshbhartia@gmail.com>
Thu, 18 May 2023 11:06:48 +0000 (16:36 +0530)
move
There was a use after move issue in RGWRados::cls_bucket_list_ordered
where dirent.key might be logged after it has been moved. This is fixed
by copying the key before the move.

Signed-off-by: Vedansh Bhartia <vedanshbhartia@gmail.com>
src/rgw/driver/rados/rgw_rados.cc

index c71848bbfd00cc9f81f20506daba178a88ae67c9..e6f2c836cf01cce70df6f44d5da4c3af452e8360 100644 (file)
@@ -8866,10 +8866,12 @@ int RGWRados::cls_bucket_list_ordered(const DoutPrefixProvider *dpp,
       r = 0;
     }
 
+    const cls_rgw_obj_key dirent_key = dirent.key;
+
     // at this point either r >= 0 or r == -ENOENT
     if (r >= 0) { // i.e., if r != -ENOENT
       ldpp_dout(dpp, 10) << __func__ << ": got " <<
-       dirent.key << dendl;
+       dirent_key << dendl;
 
       auto [it, inserted] = m.insert_or_assign(name, std::move(dirent));
       last_entry_visited = &it->second;
@@ -8910,7 +8912,7 @@ int RGWRados::cls_bucket_list_ordered(const DoutPrefixProvider *dpp,
       // fewer than what was requested
       ldpp_dout(dpp, 10) << __func__ <<
        ": stopped accumulating results at count=" << count <<
-       ", dirent=\"" << dirent.key <<
+       ", dirent=\"" << dirent_key <<
        "\", because its shard is truncated and exhausted" << dendl;
       break;
     }