]> granicus.if.org Git - pdns/commitdiff
forgot to commit this one - use dns_random() in more places
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 9 Jun 2008 09:19:52 +0000 (09:19 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 9 Jun 2008 09:19:52 +0000 (09:19 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1188 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/resolver.cc

index 9feed614f26a1164e7764a7108c84825b8c897fd..cff098bcabdf1fcb77467ef900a8087cfb95ec0d 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2002 - 2007 PowerDNS.COM BV
+    Copyright (C) 2002 - 2008 PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as 
@@ -37,6 +37,7 @@
 #include "dnswriter.hh"
 #include "dnsparser.hh"
 #include <boost/shared_ptr.hpp>
+#include "dns_random.hh"
 
 using namespace boost;
 
@@ -65,7 +66,7 @@ void Resolver::makeSocket(int type)
 
   int tries=10;
   while(--tries) {
-    sin.sin_port = htons(10000+(random()%10000));
+    sin.sin_port = htons(10000+(dns_random(10000)));
   
     if (bind(d_sock, (struct sockaddr *)&sin, sizeof(sin)) >= 0) 
       break;
@@ -153,7 +154,7 @@ void Resolver::sendResolve(const string &ip, const char *domain, int type)
 {
   vector<uint8_t> packet;
   DNSPacketWriter pw(packet, domain, type);
-  pw.getHeader()->id = d_randomid = random();
+  pw.getHeader()->id = d_randomid = dns_random(0xffff);
 
   d_domain=domain;
   d_type=type;
@@ -300,7 +301,7 @@ int Resolver::axfr(const string &ip, const char *domain)
   
   vector<uint8_t> packet;
   DNSPacketWriter pw(packet, domain, QType::AXFR);
-  pw.getHeader()->id = d_randomid = random();
+  pw.getHeader()->id = d_randomid = dns_random(0xffff);
 
   uint16_t replen=htons(packet.size());
   Utility::iovec iov[2];