]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: enforce S3 object name restrictions
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 10 Jan 2016 00:07:28 +0000 (19:07 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:07:43 +0000 (12:07 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.h

index 84556f705417280e18a0fb33e4e0abff025ec6cf..c3953779986bfeb1441c7f0f42cb8956ac818ecc 100644 (file)
@@ -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;
   }