]> granicus.if.org Git - pdns/commitdiff
remove one unneccessary layer of (un)base32hex transitions, spotted by Aki Tuomi
authorBert Hubert <bert.hubert@netherlabs.nl>
Fri, 7 Jan 2011 20:01:43 +0000 (20:01 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Fri, 7 Jan 2011 20:01:43 +0000 (20:01 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1829 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/packethandler.cc

index c38d3ee1942f6a79635a0af504cfd6c7a64ed6de..15c7d4441353efa67d6e2b668c919ee253a4c28f 100644 (file)
@@ -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: "<<hashed<<", "<<unhashed<<", "<<before<<", "<<after<<endl;
   return ret;
@@ -609,7 +605,7 @@ void PacketHandler::addNSEC3(DNSPacket *p, DNSPacket *r, const string& target, c
 
   // now add the closest encloser
   unhashed=auth;
-  hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3rc.d_iterations, ns3rc.d_salt, unhashed)));
+  hashed=hashQNameWithSalt(ns3rc.d_iterations, ns3rc.d_salt, unhashed);
   
   getNSEC3Hashes(narrow, sd.db, sd.domain_id,  hashed, false, unhashed, before, after); 
   cerr<<"Done calling for closest encloser, before='"<<before<<"', after='"<<after<<"'"<<endl;