From: Adam C. Emerson Date: Tue, 24 Mar 2026 22:21:30 +0000 (-0400) Subject: rgw/cors: Remove VLA from `lowercase_http_attr` X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bda6c07813565ae5314331398c098b730fa44e2a;p=ceph.git rgw/cors: Remove VLA from `lowercase_http_attr` Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/rgw_cors.cc b/src/rgw/rgw_cors.cc index 049e0ab0eace..a7305fff7218 100644 --- a/src/rgw/rgw_cors.cc +++ b/src/rgw/rgw_cors.cc @@ -95,16 +95,15 @@ list RGWCORSRule::generate_test_instances() * * @todo When UTF-8 is allowed in HTTP headers, this function will need to change */ -string lowercase_http_attr(const string& orig) +std::string +lowercase_http_attr(const std::string& orig) { - const char *s = orig.c_str(); - char buf[orig.size() + 1]; - buf[orig.size()] = '\0'; - - for (size_t i = 0; i < orig.size(); ++i, ++s) { - buf[i] = tolower(*s); - } - return string(buf); + std::string s; + s.reserve(orig.size()); + std::ranges::transform(orig, std::back_inserter(s), [](char c) -> char { + return tolower(static_cast(c)); + }); + return s; }