From: Robin H. Johnson Date: Thu, 16 Mar 2017 06:04:00 +0000 (-0700) Subject: rgw: fix Swift container naming rules. X-Git-Tag: v13.0.1~309^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f9107fb08c4ddc369c82d46fff0762bbda4b008;p=ceph.git rgw: fix Swift container naming rules. 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 --- diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index c3c44fa4d04..5475e353cd5 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -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; } diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 1af9612e888..22b6dcff962 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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;