]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw:fix radosgw-admin use after free 61244/head
authorAlex Wojno <awojno@bloomberg.net>
Thu, 9 Jan 2025 19:30:24 +0000 (19:30 +0000)
committerAlex Wojno <awojno@bloomberg.net>
Thu, 9 Jan 2025 19:33:32 +0000 (19:33 +0000)
Converted string_view members to string to avoid use after free.

Bug introduced in commit: e84c7fc

Signed-off-by: Alex Wojno <awojno@bloomberg.net>
src/rgw/radosgw-admin/radosgw-admin.cc

index 182e42b8e31f71c6eb81bc6a6a22ca84d2478829..cf405181ea879989b6b02d00684607d77727c865 100644 (file)
@@ -2540,8 +2540,8 @@ static void sync_status(Formatter *formatter)
 
 struct indented {
   int w; // indent width
-  std::string_view header;
-  indented(int w, std::string_view header = "") : w(w), header(header) {}
+  std::string header;
+  indented(int w, std::string header = "") : w(w), header(header) {}
 };
 std::ostream& operator<<(std::ostream& out, const indented& h) {
   return out << std::setw(h.w) << h.header << std::setw(1) << ' ';
@@ -2549,10 +2549,10 @@ std::ostream& operator<<(std::ostream& out, const indented& h) {
 
 struct bucket_source_sync_info {
   const RGWZone& _source;
-  std::string_view error;
+  std::string error;
   std::map<int,std::string> shards_behind;
   int total_shards;
-  std::string_view status;
+  std::string status;
   rgw_bucket bucket_source;
 
   bucket_source_sync_info(const RGWZone& source): _source(source) {}
@@ -3072,14 +3072,12 @@ static int bucket_sync_status(rgw::sal::Driver* driver, const RGWBucketInfo& inf
       }
       if (pipe.source.zone.value_or(rgw_zone_id()) == z->second.id) {
         bucket_source_sync_info source_sync_info(z->second);
-       auto ret = bucket_source_sync_status(dpp(), static_cast<rgw::sal::RadosStore*>(driver), static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->get_zone(), z->second,
+        bucket_source_sync_status(dpp(), static_cast<rgw::sal::RadosStore*>(driver), static_cast<rgw::sal::RadosStore*>(driver)->svc()->zone->get_zone(), z->second,
                                  c->second,
                                  info, pipe,
                                  source_sync_info);
 
-        if (ret == 0) {
-          bucket_sync_info.source_status_info.emplace_back(std::move(source_sync_info));
-        }
+        bucket_sync_info.source_status_info.emplace_back(std::move(source_sync_info));
       }
     }
   }