From 04285687fb9303eb073767034c8db61bf335b864 Mon Sep 17 00:00:00 2001 From: Marcio Roberto Starke Date: Tue, 14 Mar 2023 16:15:50 -0300 Subject: [PATCH] rgw/swift: check position of first slash in slo manifest files 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 (cherry picked from commit 167c016434f2928a35d8cd1aec156c896830c5e4) --- src/rgw/rgw_op.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index d208e5d2c5e..27a23eada56 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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); -- 2.39.5