]> granicus.if.org Git - pdns/commitdiff
spotted by Wouter Wijngaards, turns out we were incrementing/decrementing already...
authorBert Hubert <bert.hubert@netherlabs.nl>
Thu, 6 Jan 2011 13:03:50 +0000 (13:03 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Thu, 6 Jan 2011 13:03:50 +0000 (13:03 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1813 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/packethandler.cc

index d95daa68ecb0eb2b57ddfbe33fb0eacab8a51a48..3570ffe0bde064d975ab0075f6ca4fc9cad05099 100644 (file)
@@ -541,32 +541,38 @@ 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? ;-)
 {
   if(hash.empty())
     return;
-  for(string::size_type pos=hash.size(); pos; ) {
+  string raw=fromBase32Hex(hash);
+  for(string::size_type pos=raw.size(); pos; ) {
     --pos;
-    unsigned char c = (unsigned char)hash[pos];
+    unsigned char c = (unsigned char)raw[pos];
     ++c;
-    hash[pos] = (char) c;
+    raw[pos] = (char) c;
     if(c)
       break;
   }
+  hash=toBase32Hex(raw);
 }
 
 static void decrementHash(std::string& hash) // I wonder if this is correct, cmouse? ;-)
 {
   if(hash.empty())
     return;
-  for(string::size_type pos=hash.size(); pos; ) {
+    
+  string raw=fromBase32Hex(hash);
+  for(string::size_type pos=raw.size(); pos; ) {
     --pos;
-    unsigned char c = (unsigned char)hash[pos];
+    unsigned char c = (unsigned char)raw[pos];
     --c;
-    hash[pos] = (char) c;
+    raw[pos] = (char) c;
     if(c != 0xff)
       break;
   }
+  hash = toBase32Hex(raw);
 }