From: bert hubert Date: Thu, 10 Dec 2015 06:35:00 +0000 (+0100) Subject: so, it turns out only the hashing/dnssec parts of powerdns need 'toDNSString()' lower... X-Git-Tag: dnsdist-1.0.0-alpha1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ba4e1ee999652a52e9bcce42faeb7b1d16e97a8;p=thirdparty%2Fpdns.git so, it turns out only the hashing/dnssec parts of powerdns need 'toDNSString()' lowercase. Gave them a helper, made toDNSString() not touch case again. --- diff --git a/pdns/dnsname.cc b/pdns/dnsname.cc index cfd38efa02..f2535a46cd 100644 --- a/pdns/dnsname.cc +++ b/pdns/dnsname.cc @@ -115,9 +115,12 @@ std::string DNSName::toDNSString() const if (empty()) throw std::out_of_range("Attempt to DNSString an unset dnsname"); - string ret(d_storage.c_str(), d_storage.length()); - return toLower(ret); // toLower or not toLower, that is the question - // return ret; + return std::string(d_storage.c_str(), d_storage.length()); +} + +std::string DNSName::toDNSStringLC() const +{ + return toLower(toDNSString()); // label lengths are always < 'A' } /** diff --git a/pdns/dnsname.hh b/pdns/dnsname.hh index 3c1a2360bd..5dbd6fc3e4 100644 --- a/pdns/dnsname.hh +++ b/pdns/dnsname.hh @@ -43,6 +43,7 @@ public: std::string toStringNoDot() const { return toString(".", false); } std::string toStringRootDot() const { if(isRoot()) return "."; else return toString(".", false); } std::string toDNSString() const; //!< Our representation in DNS native format + std::string toDNSStringLC() const; //!< Our representation in DNS native format, lower cased void appendRawLabel(const std::string& str); //!< Append this unescaped label void appendRawLabel(const char* start, unsigned int length); //!< Append this unescaped label void prependRawLabel(const std::string& str); //!< Prepend this unescaped label diff --git a/pdns/dnssecinfra.cc b/pdns/dnssecinfra.cc index 2f30e3d832..357f20a007 100644 --- a/pdns/dnssecinfra.cc +++ b/pdns/dnssecinfra.cc @@ -310,7 +310,7 @@ string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, v toHash.resize(toHash.size() - rrc.d_signature.length()); // chop off the end, don't sign the signature! for(shared_ptr& add : signRecords) { - toHash.append(qname.toDNSString()); // FIXME400 tolower? + toHash.append(qname.toDNSStringLC()); uint16_t tmp=htons(rrc.d_type); toHash.append((char*)&tmp, 2); tmp=htons(1); // class @@ -329,7 +329,7 @@ string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, v DSRecordContent makeDSFromDNSKey(const DNSName& qname, const DNSKEYRecordContent& drc, int digest) { string toHash; - toHash.assign(qname.toDNSString()); // FIXME400 tolower? + toHash.assign(qname.toDNSStringLC()); toHash.append(const_cast(drc).serialize(DNSName(), true, true)); DSRecordContent dsrc; @@ -399,7 +399,7 @@ string hashQNameWithSalt(const NSEC3PARAMRecordContent& ns3prc, const DNSName& q { unsigned int times = ns3prc.d_iterations; unsigned char hash[20]; - string toHash(qname.toDNSString()); + string toHash(qname.toDNSStringLC()); for(;;) { toHash.append(ns3prc.d_salt);