]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix Swift container naming rules. 13992/head
authorRobin H. Johnson <robin.johnson@dreamhost.com>
Thu, 16 Mar 2017 06:04:00 +0000 (23:04 -0700)
committerRobin H. Johnson <robin.johnson@dreamhost.com>
Tue, 28 Mar 2017 18:43:53 +0000 (11:43 -0700)
Swift containers are declared in the upstream documentation as 1-256
bytes of UTF-8, and the only forbidden character is '/'.

We did not previously enforce the no-slash rule.

Also ensure that the common validate_bucket_name does not permit '/' or
0xFF either (it's also banned in S3).

See-Also: https://docs.openstack.org/developer/swift/api/object_api_v1_overview.html
Fixes: http://tracker.ceph.com/issues/19264
Backport: hammer, jewel
Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
src/rgw/rgw_rest.cc
src/rgw/rgw_rest_swift.cc

index c3c44fa4d04bf854238c9b43174b319067541c16..5475e353cd50899999dc2ef3864a4b5c185cc956 100644 (file)
@@ -1636,6 +1636,14 @@ int RGWHandler_REST::validate_bucket_name(const string& bucket)
     return -ERR_INVALID_BUCKET_NAME;
   }
 
+  const char *s = bucket.c_str();
+  for (int i = 0; i < len; ++i, ++s) {
+    if (*(unsigned char *)s == 0xff)
+      return -ERR_INVALID_BUCKET_NAME;
+    if (*(unsigned char *)s == '/')
+      return -ERR_INVALID_BUCKET_NAME;
+  }
+
   return 0;
 }
 
index 1af9612e888ea9c8ba28bfab53c704f7015317df..22b6dcff9629e3af97f6eefd0e4c667d5d0af625 100644 (file)
@@ -2228,6 +2228,8 @@ int RGWHandler_REST_SWIFT::validate_bucket_name(const string& bucket)
   for (int i = 0; i < len; ++i, ++s) {
     if (*(unsigned char *)s == 0xff)
       return -ERR_INVALID_BUCKET_NAME;
+    if (*(unsigned char *)s == '/')
+      return -ERR_INVALID_BUCKET_NAME;
   }
 
   return 0;