From f1be1d26a1ea68c9c182cb24de4b3a1ef428fc67 Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Fri, 1 Jul 2022 23:19:40 +0200 Subject: [PATCH] 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) (cherry picked from commit e2b923600c28626b921107c13e2c12d691eed3f1) --- src/rgw/rgw_rest_s3.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 1cb855d09e306..ff2af574fba22 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -4983,9 +4983,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::Bucket::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; -- 2.39.5