From fc75d15f45596fa9ae4aeb704fe2a461ae09d603 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 14 Jan 2021 08:41:16 -0500 Subject: [PATCH] rgw: fix trailing null in object names of multipart reuploads the overload being called had a comment saying: /* size should be the required string size + 1 */ this calls a different overload that returns std::string and handles this null termination correctly Fixes: https://tracker.ceph.com/issues/48874 Signed-off-by: Casey Bodley (cherry picked from commit 2ede30782b00fe28ac714047f55b11b76ae1593f) --- src/rgw/rgw_putobj_processor.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index 2906e13c1cc0..11b8db58499f 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -336,8 +336,7 @@ int MultipartObjectProcessor::process_first_chunk(bufferlist&& data, int r = writer.write_exclusive(data); if (r == -EEXIST) { // randomize the oid prefix and reprepare the head/manifest - std::string oid_rand(32, 0); - gen_rand_alphanumeric(store->ctx(), oid_rand.data(), oid_rand.size()); + std::string oid_rand = gen_rand_alphanumeric(store->ctx(), 32); mp.init(target_obj->get_name(), upload_id, oid_rand); manifest.set_prefix(target_obj->get_name() + "." + oid_rand); -- 2.47.3