From: Casey Bodley Date: Thu, 14 Jan 2021 13:41:16 +0000 (-0500) Subject: rgw: fix trailing null in object names of multipart reuploads X-Git-Tag: v14.2.17~17^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c4f4bfbce98b730105729d0153a4b9f2290e0311;p=ceph.git 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) --- diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index f3ef5d7c54c..3de30a82e3d 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -338,8 +338,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.key.name, upload_id, oid_rand); manifest.set_prefix(target_obj.key.name + "." + oid_rand);