From 6ee4f649735d549fc4c032414b8a94d9e822a349 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 20 Apr 2015 14:47:16 -0700 Subject: [PATCH] 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 --- src/rgw/rgw_common.h | 1 + src/rgw/rgw_http_errors.h | 1 + src/rgw/rgw_op.cc | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index a26d96e7c0fe2..a1ae4d975f2ba 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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 diff --git a/src/rgw/rgw_http_errors.h b/src/rgw/rgw_http_errors.h index 7850807b6024b..78776f46339bc 100644 --- a/src/rgw/rgw_http_errors.h +++ b/src/rgw/rgw_http_errors.h @@ -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" }, diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 1ab9049f0844a..23a7debb595e3 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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(parser.find_first("CompleteMultipartUpload")); - if (!parts) { - ret = -EINVAL; + if (!parts || parts->parts.size() == 0) { + ret = -ERR_MALFORMED_XML; return; } -- 2.39.5