]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make dns hostnames matching case insensitive
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 29 Jul 2019 12:37:40 +0000 (14:37 +0200)
committerNathan Cutler <ncutler@suse.com>
Fri, 13 Sep 2019 09:41:41 +0000 (11:41 +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>
(cherry picked from commit 9bc7d7bd0cf42663ebf1131d9cac6c96e6d9f141)

src/rgw/rgw_rest.cc

index 67de9bb9b068cb7ecb3cced61e43615bb99ead25..c30f4331b9d1c9267383f2194dcf82217efd2560 100644 (file)
@@ -277,7 +277,7 @@ void rgw_rest_init(CephContext *cct, RGWRados *store, RGWZoneGroup& zone_group)
    */
 }
 
-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()) {
@@ -289,7 +289,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)
@@ -301,7 +301,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) {