Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw_file: ensure valid_s3_object_name for directories, too #13614

Merged
merged 1 commit into from Feb 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/rgw/rgw_file.cc
Expand Up @@ -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;
Expand All @@ -457,13 +459,25 @@ 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() != '/'))
dir_name += "/";
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);

Expand Down