]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: ensure valid_s3_object_name for directories, too 13614/head
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 23 Feb 2017 21:02:07 +0000 (16:02 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Thu, 23 Feb 2017 21:02:07 +0000 (16:02 -0500)
The logic in RGWLibFS::mkdir() validated bucket names, but not
object names (though RGWLibFS::create() did so).

The negative side effect of this was not creating illegal objects
(we won't), but in a) failing with -EIO and b) more importantly,
not removing up the proposed object from FHCache, which produced a
boost assert when recycled.

Fixes: http://tracker.ceph.com/issues/19066
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc

index 4e5108c87e66098109bfeba41b32d3095232300f..a2a324cc5b91c8f4d318a783b32db8e1ec8c9b78 100644 (file)
@@ -437,6 +437,8 @@ namespace rgw {
       rc = valid_s3_bucket_name(bname, false /* relaxed */);
       if (rc != 0) {
        rgw_fh->flags |= RGWFileHandle::FLAG_DELETED;
+       fh_cache.remove(rgw_fh->fh.fh_hk.object, rgw_fh,
+                       RGWFileHandle::FHCache::FLAG_LOCK);
        rgw_fh->mtx.unlock();
        unref(rgw_fh);
        get<0>(mkr) = nullptr;
@@ -457,6 +459,7 @@ namespace rgw {
       buffer::list bl;
       string dir_name = /* XXX get rid of this some day soon, too */
        parent->relative_object_name();
+
       /* creating objects w/leading '/' makes a mess */
       if ((dir_name.size() > 0) &&
          (dir_name.back() != '/'))
@@ -464,6 +467,17 @@ namespace rgw {
       dir_name += name;
       dir_name += "/";
 
+      /* need valid S3 name (characters, length <= 1024, etc) */
+      if (! valid_s3_object_name(dir_name)) {
+       rgw_fh->flags |= RGWFileHandle::FLAG_DELETED;
+       fh_cache.remove(rgw_fh->fh.fh_hk.object, rgw_fh,
+                       RGWFileHandle::FHCache::FLAG_LOCK);
+       rgw_fh->mtx.unlock();
+       unref(rgw_fh);
+       get<0>(mkr) = nullptr;
+       return mkr;
+      }
+
       RGWPutObjRequest req(get_context(), get_user(), parent->bucket_name(),
                          dir_name, bl);