From: Soumya Koduri Date: Thu, 26 May 2022 16:55:06 +0000 (+0530) Subject: rgw: Avoid dereferencing nullptr while configuring bucket sync policy X-Git-Tag: v17.2.4~31^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bb84fce4eae81e6c37cfc035f1d969649100b97c;p=ceph.git rgw: Avoid dereferencing nullptr while configuring bucket sync policy While configuring bucket sync policy, in "rgw_sync_bucket_entities::set_bucket()", there could be a case where in bucket doesnt contain any value but is still being dereferenced. This commit fixes the same. Signed-off-by: Soumya Koduri (cherry picked from commit 86cf8275224536a7ca77eaf8a6e59951b3f25261) --- diff --git a/src/rgw/rgw_sync_policy.cc b/src/rgw/rgw_sync_policy.cc index b7a8adafcee7..cf28d5eecc48 100644 --- a/src/rgw/rgw_sync_policy.cc +++ b/src/rgw/rgw_sync_policy.cc @@ -258,6 +258,10 @@ void rgw_sync_bucket_entities::set_bucket(std::optional tenant, bucket.emplace(); } + if (!bucket) { + return; + } + set_bucket_field(tenant, &bucket->tenant); set_bucket_field(bucket_name, &bucket->name); set_bucket_field(bucket_id, &bucket->bucket_id);