From: Miod Vallat Date: Fri, 25 Jul 2025 12:59:06 +0000 (+0200) Subject: More use of hasLabels X-Git-Tag: auth-5.1.0-alpha0^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f2c746ca6bbf4721fdbc1afbf4301ed4e6fd34e;p=thirdparty%2Fpdns.git More use of hasLabels Signed-off-by: Miod Vallat --- diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 5f7407fa1..a51309887 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -333,8 +333,7 @@ void DNSPacket::wrapup(bool throwsOnTruncation) } } - if (d_trc.d_algoName.countLabels()) - { + if (d_trc.d_algoName.hasLabels()) { // TSIG is not OPT, but we count it in optsize anyway optsize += d_trc.d_algoName.wirelength() + 3 + 1 + 2; // algo + time + fudge + maclen optsize += EVP_MAX_MD_SIZE + 2 + 2 + 2 + 0; // mac + origid + ercode + otherdatalen + no other data @@ -400,8 +399,9 @@ void DNSPacket::wrapup(bool throwsOnTruncation) } } - if(d_trc.d_algoName.countLabels()) + if(d_trc.d_algoName.hasLabels()) { addTSIG(pw, d_trc, d_tsigkeyname, d_tsigsecret, d_tsigprevious, d_tsigtimersonly); + } d_rawpacket.assign((char*)&packet[0], packet.size()); // XXX we could do this natively on a vector.. @@ -458,7 +458,7 @@ std::unique_ptr DNSPacket::replyPacket() const r->d_ednsrcode = 0; r->d_xfr = d_xfr; - if(d_tsigkeyname.countLabels()) { + if(d_tsigkeyname.hasLabels()) { r->d_tsigkeyname = d_tsigkeyname; r->d_tsigprevious = d_tsigprevious; r->d_trc = d_trc; diff --git a/pdns/nsec3dig.cc b/pdns/nsec3dig.cc index a5d6dcb5e..1a7c04a01 100644 --- a/pdns/nsec3dig.cc +++ b/pdns/nsec3dig.cc @@ -253,7 +253,7 @@ try } prev=shorter; } - if(encloser.countLabels() && nextcloser.countLabels()) + if(encloser.hasLabels() && nextcloser.hasLabels()) { if(denied.count(nextcloser)) { diff --git a/pdns/resolver.cc b/pdns/resolver.cc index 7baede556..530a562ac 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -202,7 +202,7 @@ namespace pdns { if(mdp.d_header.rcode) return mdp.d_header.rcode; - if(origQname.countLabels()) { // not AXFR + if(origQname.hasLabels()) { // not AXFR if(mdp.d_header.id != id) throw ResolverException("Remote nameserver replied with wrong id"); if(mdp.d_header.qdcount != 1) diff --git a/pdns/zone2ldap.cc b/pdns/zone2ldap.cc index ae46bea35..2277e6c78 100644 --- a/pdns/zone2ldap.cc +++ b/pdns/zone2ldap.cc @@ -91,11 +91,11 @@ static void callback_simple( unsigned int domain_id, const DNSName &domain, cons std::string stripped=stripDot(content); std::string rrvalue = stripped + ((stripped.empty() || stripped[stripped.size()-1]==' ') ? "." : ""); std::string dn = "dc="; - if( host.countLabels() ) { dn += host.toStringNoDot() + ",dc="; } + if( host.hasLabels() ) { dn += host.toStringNoDot() + ",dc="; } dn += g_zonename.toStringNoDot() + "," + g_basedn; cout << "dn: " << dn << endl; - if( host.countLabels() == 0 ) { host = g_zonename.operator const DNSName&(); } + if( !host.hasLabels() ) { host = g_zonename.operator const DNSName&(); } if( !g_entries[dn] ) {