From 4cb8270379e93d42a08b1e7b36c64716a1ac9ad7 Mon Sep 17 00:00:00 2001 From: Emin Date: Wed, 21 May 2025 14:53:45 +0200 Subject: [PATCH] fix:Add empty string check after url_decode Signed-off-by: Emin (cherry picked from commit c43ea6253d01c538ea08b371b159a7360c2042cf) --- src/rgw/rgw_op.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 81c32f5449b86..2eda52235a47b 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -4001,6 +4001,12 @@ int RGWPutObj::init_processing(optional_yield y) { copy_source_object_name = url_decode(copy_source_object_name.substr(0, pos)); } + if (copy_source_object_name.empty()) { + //means url_decode returned empty string so the url is formatted badly + ret = -EINVAL; + ldpp_dout(this, 5) << "x-amz-copy-source bad format" << dendl; + return ret; + } pos = copy_source_bucket_name.find(":"); if (pos == std::string::npos) { // if tenant is not specified in x-amz-copy-source, use tenant of the requester -- 2.39.5