]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/cors: Remove VLA from `lowercase_http_attr`
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 24 Mar 2026 22:21:30 +0000 (18:21 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Thu, 26 Mar 2026 04:07:20 +0000 (00:07 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_cors.cc

index 049e0ab0eacec07791ffea73a34183d41e8af59c..a7305fff72184c08ab88570f48d402c7cd7d7b48 100644 (file)
@@ -95,16 +95,15 @@ list<RGWCORSRule> 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<unsigned char>(c));
+  });
+  return s;
 }