Merge pull request #23626 from Liuchang0812/rgw-put-cors-compatible

rgw: return err_malformed_xml when MaxAgeSeconds is an invalid integer

Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Casey Bodley 2018-09-05 09:20:18 -04:00 committed by GitHub
commit 15a0f1ec33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -127,6 +127,10 @@ bool RGWCORSRule_S3::xml_end(const char *el) {
char *end = NULL;
unsigned long long ull = strtoull(obj->get_data().c_str(), &end, 10);
if (*end != '\0') {
dout(0) << "RGWCORSRule's MaxAgeSeconds " << obj->get_data() << " is an invalid integer" << dendl;
return false;
}
if (ull >= 0x100000000ull) {
max_age = CORS_MAX_AGE_INVALID;
} else {

View File

@ -2372,13 +2372,13 @@ int RGWPutCORS_ObjStore_S3::get_params()
}
if (!data || !parser.parse(data, len, 1)) {
return -EINVAL;
return -ERR_MALFORMED_XML;
}
cors_config =
static_cast<RGWCORSConfiguration_S3 *>(parser.find_first(
"CORSConfiguration"));
if (!cors_config) {
return -EINVAL;
return -ERR_MALFORMED_XML;
}
#define CORS_RULES_MAX_NUM 100