From f9189af194267adfb700b2f7da044ab17bb5d2ad Mon Sep 17 00:00:00 2001 From: mengxiangrui Date: Sat, 17 Jul 2021 05:22:42 +0800 Subject: [PATCH] rgw: avoid occuring radosgw daemon crash when access a conditionally redirected static website Fixes: https://tracker.ceph.com/issues/51715 Signed-off-by: xiangrui meng Signed-off-by: yupeng chen (cherry picked from commit 865d13e9fa043954dce5110f4f8ae693af9604ce) --- src/rgw/rgw_website.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_website.cc b/src/rgw/rgw_website.cc index 4369ac752dc23..ff58786c77d0f 100644 --- a/src/rgw/rgw_website.cc +++ b/src/rgw/rgw_website.cc @@ -45,7 +45,9 @@ void RGWBWRoutingRule::apply_rule(const string& default_protocol, const string& if (!redirect_info.replace_key_prefix_with.empty()) { *new_url += redirect_info.replace_key_prefix_with; - *new_url += key.substr(condition.key_prefix_equals.size()); + if (key.size() > condition.key_prefix_equals.size()) { + *new_url += key.substr(condition.key_prefix_equals.size()); + } } else if (!redirect_info.replace_key_with.empty()) { *new_url += redirect_info.replace_key_with; } else { -- 2.39.5