From: mengxiangrui Date: Fri, 16 Jul 2021 21:22:42 +0000 (+0800) Subject: rgw: avoid occuring radosgw daemon crash when access a conditionally redirected stati... X-Git-Tag: v16.2.6~91^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F42626%2Fhead;p=ceph.git 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) --- diff --git a/src/rgw/rgw_website.cc b/src/rgw/rgw_website.cc index 4369ac752dc2..ff58786c77d0 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 {