]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make dns hostnames matching case insensitive 29380/head
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 29 Jul 2019 12:37:40 +0000 (14:37 +0200)
committerAbhishek Lekshmanan <abhishek@suse.com>
Mon, 29 Jul 2019 12:37:40 +0000 (14:37 +0200)
Currently when parsing host in requests, we try to case match against supplied
hostnames set, which violates dns hostnames being case insensitive. Do a case
insensitive comparision instead

Fixes: http://tracker.ceph.com/issues/40995
Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_rest.cc

index b893e82c2c98e46079f876b227613ca850464900..8455d480befeb3f03955e88483596f70eb0653fa 100644 (file)
@@ -229,7 +229,7 @@ void rgw_rest_init(CephContext *cct, RGWRados *store, const RGWZoneGroup& zone_g
    */
 }
 
-static bool str_ends_with(const string& s, const string& suffix, size_t *pos)
+static bool str_ends_with_nocase(const string& s, const string& suffix, size_t *pos)
 {
   size_t len = suffix.size();
   if (len > (size_t)s.size()) {
@@ -241,7 +241,7 @@ static bool str_ends_with(const string& s, const string& suffix, size_t *pos)
     *pos = p;
   }
 
-  return s.compare(p, len, suffix) == 0;
+  return boost::algorithm::iends_with(suffix, s);
 }
 
 static bool rgw_find_host_in_domains(const string& host, string *domain, string *subdomain, set<string> valid_hostnames_set)
@@ -253,7 +253,7 @@ static bool rgw_find_host_in_domains(const string& host, string *domain, string
    */
   for (iter = valid_hostnames_set.begin(); iter != valid_hostnames_set.end(); ++iter) {
     size_t pos;
-    if (!str_ends_with(host, *iter, &pos))
+    if (!str_ends_with_nocase(host, *iter, &pos))
       continue;
 
     if (pos == 0) {