Skip to content

Commit 4b5f967

Browse files
authored
Merge pull request ceph#63521 from mertsunacoglu/wip-url-decode-check
fix: the RGW crash caused by special characters Reviewed-by: Casey Bodley <[email protected]>
2 parents a8bd517 + 343db61 commit 4b5f967

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/rgw/rgw_common.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ std::string url_decode(const std::string_view& src_str, bool in_query)
17721772
}
17731773
}
17741774
}
1775-
1775+
17761776
return dest_str;
17771777
}
17781778

src/rgw/rgw_op.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,13 +4031,17 @@ int RGWPutObj::init_processing(optional_yield y) {
40314031
copy_source_bucket_name = copy_source_bucket_name.substr(0, pos);
40324032
#define VERSION_ID_STR "?versionId="
40334033
pos = copy_source_object_name.find(VERSION_ID_STR);
4034-
if (pos == std::string::npos) {
4035-
copy_source_object_name = url_decode(copy_source_object_name);
4036-
} else {
4034+
if (pos != std::string::npos) {
40374035
copy_source_version_id =
40384036
copy_source_object_name.substr(pos + sizeof(VERSION_ID_STR) - 1);
40394037
copy_source_object_name =
4040-
url_decode(copy_source_object_name.substr(0, pos));
4038+
copy_source_object_name.substr(0, pos);
4039+
}
4040+
if (copy_source_object_name.empty()) {
4041+
//means copy_source_object_name is empty string so the url is formatted badly
4042+
ret = -EINVAL;
4043+
ldpp_dout(this, 5) << "x-amz-copy-source bad format" << dendl;
4044+
return ret;
40414045
}
40424046
pos = copy_source_bucket_name.find(":");
40434047
if (pos == std::string::npos) {

0 commit comments

Comments
 (0)