From: Yehuda Sadeh Date: Mon, 20 Apr 2015 21:47:16 +0000 (-0700) Subject: rgw: fail if parts not specified on complete-multipart-upload X-Git-Tag: v9.0.1~99^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6ee4f649735d549fc4c032414b8a94d9e822a349;p=ceph.git 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 --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index a26d96e7c0fe..a1ae4d975f2b 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 7850807b6024..78776f46339b 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 1ab9049f0844..23a7debb595e 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; }