]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw/swift: check position of first slash in slo manifest files
authorMarcio Roberto Starke <mrstarke@gmail.com>
Tue, 14 Mar 2023 19:15:50 +0000 (16:15 -0300)
committerAli Maredia <amaredia@redhat.com>
Fri, 19 May 2023 19:47:42 +0000 (15:47 -0400)
When handling slo manifest file, find the position of the first slash to be able to delete the segment files

Fixes: https://tracker.ceph.com/issues/58950
Signed-off-by: Marcio Roberto Starke <mrstarke@gmail.com>
(cherry picked from commit 167c016434f2928a35d8cd1aec156c896830c5e4)

src/rgw/rgw_op.cc

index d208e5d2c5ef20739434cc972c4e0d621cc81ca3..27a23eada56390569ccf34559faf9ac46ce6d609 100644 (file)
@@ -4880,14 +4880,19 @@ int RGWDeleteObj::handle_slo_manifest(bufferlist& bl, optional_yield y)
   for (const auto& iter : slo_info.entries) {
     const string& path_str = iter.path;
 
-    const size_t sep_pos = path_str.find('/', 1 /* skip first slash */);
+    const size_t pos_init = path_str.find_first_not_of('/');
+    if (std::string_view::npos == pos_init) {
+      return -EINVAL;
+    }
+
+    const size_t sep_pos = path_str.find('/', pos_init);
     if (std::string_view::npos == sep_pos) {
       return -EINVAL;
     }
 
     RGWBulkDelete::acct_path_t path;
 
-    path.bucket_name = url_decode(path_str.substr(1, sep_pos - 1));
+    path.bucket_name = url_decode(path_str.substr(pos_init, sep_pos - pos_init));
     path.obj_key = url_decode(path_str.substr(sep_pos + 1));
 
     items.push_back(path);