From: Edwin Rodriguez Date: Thu, 7 Aug 2025 15:29:00 +0000 (-0400) Subject: test: Refactor CORS configuration handling for S3 to improve clarity and efficiency X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ea4a52dd46a316460d47ac8910bcc9a272842e5b;p=ceph.git test: Refactor CORS configuration handling for S3 to improve clarity and efficiency 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 --- diff --git a/src/test/test_cors.cc b/src/test/test_cors.cc index 186f47a735e..2c2a4785bf7 100644 --- a/src/test/test_cors.cc +++ b/src/test/test_cors.cc @@ -339,12 +339,10 @@ void send_cors(set o, set 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(&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());