From 9bc7d7bd0cf42663ebf1131d9cac6c96e6d9f141 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Mon, 29 Jul 2019 14:37:40 +0200 Subject: [PATCH] rgw: make dns hostnames matching case insensitive 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 --- src/rgw/rgw_rest.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index b893e82c2c9..8455d480bef 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -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 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) { -- 2.39.5