From: Bert Hubert Date: Fri, 7 Jan 2011 20:01:43 +0000 (+0000) Subject: remove one unneccessary layer of (un)base32hex transitions, spotted by Aki Tuomi X-Git-Tag: auth-3.0~418 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96cf053dd9ea0d926693e4eb30ddb62910758a1d;p=pdns remove one unneccessary layer of (un)base32hex transitions, spotted by Aki Tuomi git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1829 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index c38d3ee19..15c7d4441 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -541,12 +541,11 @@ void PacketHandler::addNSECX(DNSPacket *p, DNSPacket *r, const string& target, c } } -//we juggle raw & base32 encoded hashes too much -static void incrementHash(std::string& hash) // I wonder if this is correct, cmouse? ;-) +static void incrementHash(std::string& raw) // I wonder if this is correct, cmouse? ;-) { - if(hash.empty()) + if(raw.empty()) return; - string raw=fromBase32Hex(hash); + for(string::size_type pos=raw.size(); pos; ) { --pos; unsigned char c = (unsigned char)raw[pos]; @@ -555,15 +554,13 @@ static void incrementHash(std::string& hash) // I wonder if this is correct, cmo if(c) break; } - hash=toBase32Hex(raw); } -static void decrementHash(std::string& hash) // I wonder if this is correct, cmouse? ;-) +static void decrementHash(std::string& raw) // I wonder if this is correct, cmouse? ;-) { - if(hash.empty()) + if(raw.empty()) return; - string raw=fromBase32Hex(hash); for(string::size_type pos=raw.size(); pos; ) { --pos; unsigned char c = (unsigned char)raw[pos]; @@ -572,7 +569,6 @@ static void decrementHash(std::string& hash) // I wonder if this is correct, cmo if(c != 0xff) break; } - hash = toBase32Hex(raw); } @@ -588,7 +584,7 @@ bool PacketHandler::getNSEC3Hashes(bool narrow, DNSBackend* db, int id, const st incrementHash(after); } else { - ret=db->getBeforeAndAfterNamesAbsolute(id, hashed, unhashed, before, after); + ret=db->getBeforeAndAfterNamesAbsolute(id, toLower(toBase32Hex(hashed)), unhashed, before, after); } // cerr<<"rgetNSEC3Hashes: "<