]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test: Refactor CORS configuration handling for S3 to improve clarity and efficiency 64963/head
authorEdwin Rodriguez <edwin.rodriguez1@ibm.com>
Thu, 7 Aug 2025 15:29:00 +0000 (11:29 -0400)
committerEdwin Rodriguez <edwin.rodriguez1@ibm.com>
Mon, 25 Aug 2025 17:20:08 +0000 (13:20 -0400)
A pointer to RGWCORSConfiguration is cast to RGWCORSConfiguration_S3 which leads to
out of bounds access. Replace the pointer ref with the proper data structure

Fixes: https://tracker.ceph.com/issues/72452
Signed-off-by: Edwin Rodriguez <edwin.rodriguez1@ibm.com>
src/test/test_cors.cc

index 186f47a735ee369aa5ab78906e1cd899970efe67..2c2a4785bf71ef36fd340a46e7dfda17078f833f 100644 (file)
@@ -339,12 +339,10 @@ void send_cors(set<string> o, set<string> h,
                unsigned max_age){
   if(g_test->get_key_type() == KEY_TYPE_S3){
     RGWCORSRule rule(o, h, e, flags, max_age);
-    RGWCORSConfiguration config;
-    config.stack_rule(rule);
     stringstream ss;
-    RGWCORSConfiguration_S3 *s3;
-    s3 = static_cast<RGWCORSConfiguration_S3 *>(&config);
-    s3->to_xml(ss);
+    RGWCORSConfiguration_S3 s3(nullptr);
+    s3.stack_rule(rule);
+    s3.to_xml(ss);
 
     g_test->send_request(string("PUT"), string("/" S3_BUCKET_NAME "?cors"), cors_read_xml, 
                          (void *)&ss, ss.str().length());