From: Matt Benjamin Date: Sun, 10 Jan 2016 00:07:28 +0000 (-0500) Subject: librgw: enforce S3 object name restrictions X-Git-Tag: v10.1.0~382^2~50 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12fd3faaec14adb957270a22d91bde75f7899cc5;p=ceph.git librgw: enforce S3 object name restrictions Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 84556f705417..c3953779986b 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -1171,6 +1171,18 @@ public: }; /* RGWDeleteBucketRequest */ +static inline bool valid_s3_object_name(const string& name) { + if (name.size() > 1024) { + // Name too long + return false; + } + if (check_utf8(name.c_str(), name.size())) { + // Object names must be valid UTF-8. + return false; + } + return true; +} + /* put object */ @@ -1203,6 +1215,10 @@ public: assert(rados_ctx); RGWOp::init(rados_ctx->store, get_state(), this); op = this; // assign self as op: REQUIRED + + if (! valid_s3_object_name(obj_name)) + return -ERR_INVALID_OBJECT_NAME; + return 0; }