rgw: fail if parts not specified on complete-multipart-upload

Fixes: #11435

A complete multipart upload should not succeed if parts were not
specified. Also, adjust return codes.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
Yehuda Sadeh 2015-04-20 14:47:16 -07:00
parent 1e912b79f5
commit 6ee4f64973
3 changed files with 8 additions and 6 deletions

View File

@ -145,6 +145,7 @@ using ceph::crypto::MD5;
#define ERR_QUOTA_EXCEEDED 2026
#define ERR_SIGNATURE_NO_MATCH 2027
#define ERR_INVALID_ACCESS_KEY 2028
#define ERR_MALFORMED_XML 2029
#define ERR_USER_SUSPENDED 2100
#define ERR_INTERNAL_ERROR 2200

View File

@ -34,6 +34,7 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = {
{ ERR_TOO_LARGE, 400, "EntityTooLarge" },
{ ERR_TOO_SMALL, 400, "EntityTooSmall" },
{ ERR_TOO_MANY_BUCKETS, 400, "TooManyBuckets" },
{ ERR_MALFORMED_XML, 400, "MalformedXML" },
{ ERR_LENGTH_REQUIRED, 411, "MissingContentLength" },
{ EACCES, 403, "AccessDenied" },
{ EPERM, 403, "AccessDenied" },

View File

@ -2968,24 +2968,24 @@ void RGWCompleteMultipart::execute()
return;
}
if (!data) {
ret = -EINVAL;
if (!data || !len) {
ret = -ERR_MALFORMED_XML;
return;
}
if (!parser.init()) {
ret = -EINVAL;
ret = -EIO;
return;
}
if (!parser.parse(data, len, 1)) {
ret = -EINVAL;
ret = -ERR_MALFORMED_XML;
return;
}
parts = static_cast<RGWMultiCompleteUpload *>(parser.find_first("CompleteMultipartUpload"));
if (!parts) {
ret = -EINVAL;
if (!parts || parts->parts.size() == 0) {
ret = -ERR_MALFORMED_XML;
return;
}