]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: s3website check for bucket before retargeting 46933/head
authorSeena Fallah <seenafallah@gmail.com>
Fri, 1 Jul 2022 21:19:40 +0000 (23:19 +0200)
committerSeena Fallah <seenafallah@gmail.com>
Thu, 7 Jul 2022 16:48:38 +0000 (18:48 +0200)
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>
src/rgw/rgw_rest_s3.cc

index 4f90abb914a4d7ddea3466f4d00afd0bf0dcd975..cd0917eb44405427b57199be02d7aa7dc5ef2fc7 100644 (file)
@@ -5128,9 +5128,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;