]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: avoid occuring radosgw daemon crash when access a conditionally redirected stati... 42626/head
authormengxiangrui <mengxr@chinatelecom.cn>
Fri, 16 Jul 2021 21:22:42 +0000 (05:22 +0800)
committerCory Snyder <csnyder@iland.com>
Wed, 4 Aug 2021 10:33:59 +0000 (06:33 -0400)
Fixes: https://tracker.ceph.com/issues/51715
Signed-off-by: xiangrui meng <mengxr@chinatelecom.cn>
Signed-off-by: yupeng chen <chenyupeng@chinatelecom.cn>
(cherry picked from commit 865d13e9fa043954dce5110f4f8ae693af9604ce)

src/rgw/rgw_website.cc

index 4369ac752dc2376de146001c4798f1b8fa14227f..ff58786c77d0fe79ed2383ba5752e54a84f13ddb 100644 (file)
@@ -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 {