]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: s3website check for bucket before retargeting
authorSeena Fallah <seenafallah@gmail.com>
Fri, 1 Jul 2022 21:19:40 +0000 (23:19 +0200)
committerDavid Galloway <dgallowa@redhat.com>
Thu, 21 Jul 2022 16:27:54 +0000 (12:27 -0400)
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 <seenafallah@gmail.com>
(cherry picked from commit 933dbabb3a2a43fd016bc61cc0ee5e27f7ad32e7)

Conflicts:
  src/rgw/rgw_rest_s3.cc rgw::sal::Bucket -> rgw::sal::RGWBucket
(cherry picked from commit 5b3e3874433acdfec415eae2b7a02878afe00734)

src/rgw/rgw_rest_s3.cc

index 724c3d30d84b79842583fe47c273013757b52afc..7dbf577b329a510e092a8d083a2ca29d026550bf 100644 (file)
@@ -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;