From: Seena Fallah Date: Fri, 1 Jul 2022 21:19:40 +0000 (+0200) Subject: rgw: s3website check for bucket before retargeting X-Git-Tag: v16.2.10~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a82c2de8ccac831651dc0333437c024c0d928676;p=ceph.git rgw: s3website check for bucket before retargeting On requesting s3website API without a bucket name it will crash because s->bucket is null Fixes: https://tracker.ceph.com/issues/56281 Signed-off-by: Seena Fallah (cherry picked from commit 933dbabb3a2a43fd016bc61cc0ee5e27f7ad32e7) Conflicts: src/rgw/rgw_rest_s3.cc rgw::sal::Bucket -> rgw::sal::RGWBucket (cherry picked from commit 5b3e3874433acdfec415eae2b7a02878afe00734) --- diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 724c3d30d84b..7dbf577b329a 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -4951,9 +4951,14 @@ int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op, optional_yiel if (!(s->prot_flags & RGW_REST_WEBSITE)) return 0; + if (rgw::sal::RGWBucket::empty(s->bucket.get())) { + // TODO-FUTURE: if the bucket does not exist, maybe expose it here? + return -ERR_NO_SUCH_BUCKET; + } + if (!s->bucket->get_info().has_website) { - // TODO-FUTURE: if the bucket has no WebsiteConfig, expose it here - return -ERR_NO_SUCH_WEBSITE_CONFIGURATION; + // TODO-FUTURE: if the bucket has no WebsiteConfig, expose it here + return -ERR_NO_SUCH_WEBSITE_CONFIGURATION; } rgw_obj_key new_obj;