From: Remi Gacogne Date: Mon, 21 Sep 2020 08:49:16 +0000 (+0200) Subject: Switch to the pdns_string_view alias to prevent collisions X-Git-Tag: auth-4.4.0-alpha1~18^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83577fb44357696ec27b13cd658384313331fcca;p=thirdparty%2Fpdns.git Switch to the pdns_string_view alias to prevent collisions --- diff --git a/pdns/dnsdist-cache.cc b/pdns/dnsdist-cache.cc index fa38fbb9dd..79f12234f2 100644 --- a/pdns/dnsdist-cache.cc +++ b/pdns/dnsdist-cache.cc @@ -429,7 +429,7 @@ uint32_t DNSDistPacketCache::getKey(const DNSName::string_t& qname, uint16_t con if (packetLen > ((sizeof(dnsheader) + consumed))) { if (!d_cookieHashing) { /* skip EDNS Cookie options if any */ - result = PacketCache::hashAfterQname(string_view(reinterpret_cast(packet), packetLen), result, sizeof(dnsheader) + consumed, false); + result = PacketCache::hashAfterQname(pdns_string_view(reinterpret_cast(packet), packetLen), result, sizeof(dnsheader) + consumed, false); } else { result = burtle(packet + sizeof(dnsheader) + consumed, packetLen - (sizeof(dnsheader) + consumed), result); diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index 24e17b000c..080c95e3b8 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -710,15 +710,15 @@ static void doh_dispatch_query(DOHServerConfig* dsc, h2o_handler_t* self, h2o_re } /* can only be called from the main DoH thread */ -static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerName, string_view& value) +static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerName, pdns_string_view& value) { bool found = false; /* early versions of boost::string_ref didn't have the ability to compare to string */ - string_view headerNameView(headerName); + pdns_string_view headerNameView(headerName); for (size_t i = 0; i < req->headers.size; ++i) { - if (string_view(req->headers.entries[i].name->base, req->headers.entries[i].name->len) == headerNameView) { - value = string_view(req->headers.entries[i].value.base, req->headers.entries[i].value.len); + if (pdns_string_view(req->headers.entries[i].name->base, req->headers.entries[i].name->len) == headerNameView) { + value = pdns_string_view(req->headers.entries[i].value.base, req->headers.entries[i].value.len); /* don't stop there, we might have more than one header with the same name, and we want the last one */ found = true; } @@ -731,12 +731,12 @@ static bool getHTTPHeaderValue(const h2o_req_t* req, const std::string& headerNa static void processForwardedForHeader(const h2o_req_t* req, ComboAddress& remote) { static const std::string headerName = "x-forwarded-for"; - string_view value; + pdns_string_view value; if (getHTTPHeaderValue(req, headerName, value)) { try { auto pos = value.rfind(','); - if (pos != string_view::npos) { + if (pos != pdns_string_view::npos) { ++pos; for (; pos < value.size() && value[pos] == ' '; ++pos) { diff --git a/pdns/packetcache.hh b/pdns/packetcache.hh index a8cf718888..da3b62190d 100644 --- a/pdns/packetcache.hh +++ b/pdns/packetcache.hh @@ -34,7 +34,7 @@ public: - EDNS Cookie options, if any ; - EDNS Client Subnet options, if any and skipECS is true. */ - static uint32_t hashAfterQname(const string_view& packet, uint32_t currentHash, size_t pos, bool skipECS) + static uint32_t hashAfterQname(const pdns_string_view& packet, uint32_t currentHash, size_t pos, bool skipECS) { const size_t packetSize = packet.size(); assert(packetSize >= sizeof(dnsheader)); diff --git a/pdns/views.hh b/pdns/views.hh index 21fa8bb2ce..d931c09436 100644 --- a/pdns/views.hh +++ b/pdns/views.hh @@ -23,18 +23,18 @@ #pragma once #ifdef __cpp_lib_string_view -using std::string_view; +using pdns_string_view = std::string_view; #else #include #if BOOST_VERSION >= 106400 // string_view already exists in 1.61.0 but string_view::at() is not usable with modern compilers, see: // https://github.com/boostorg/utility/pull/26 #include -using boost::string_view; +using pdns_string_view = boost::string_view; #elif BOOST_VERSION >= 105300 #include -using string_view = boost::string_ref; +using pdns_string_view = boost::string_ref; #else -using string_view = std::string; +using pdns_string_view = std::string; #endif #endif