]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1607. [bug] dig, host and nslookup were still using random()
authorMark Andrews <marka@isc.org>
Thu, 8 Apr 2004 01:21:16 +0000 (01:21 +0000)
committerMark Andrews <marka@isc.org>
Thu, 8 Apr 2004 01:21:16 +0000 (01:21 +0000)
                        to generate query ids. [RT# 11013]

CHANGES
bin/dig/dighost.c

diff --git a/CHANGES b/CHANGES
index 33178b1432083b51aba3042c380968d3b6ce7339..894647d9930a8f1378797910d994ee3baf1e1858 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+1607.  [bug]           dig, host and nslookup were still using random()
+                       to generate query ids. [RT# 11013]
+
 1606.  [placeholder]   rt10440a
 
 1605.  [placeholder]   rt10440a
index 3f7e799cbf07cf1567aecc9a11e4a9d9f1848422..be3d2d7062ada9b8eea608f04f9a86f553c32355 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.259 2004/03/05 04:57:30 marka Exp $ */
+/* $Id: dighost.c,v 1.260 2004/04/08 01:21:16 marka Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -53,6 +53,7 @@
 #include <isc/lang.h>
 #include <isc/netaddr.h>
 #include <isc/print.h>
+#include <isc/random.h>
 #include <isc/result.h>
 #include <isc/string.h>
 #include <isc/task.h>
@@ -806,13 +807,6 @@ setup_libs(void) {
 
        debug("setup_libs()");
 
-       /*
-        * Warning: This is not particularly good randomness.  We'll
-        * just use random() now for getting id values, but doing so
-        * does NOT ensure that id's can't be guessed.
-        */
-       srandom(getpid());
-
        result = isc_net_probeipv4();
        if (result == ISC_R_SUCCESS)
                have_ipv4 = ISC_TRUE;
@@ -1284,6 +1278,7 @@ insert_soa(dig_lookup_t *lookup) {
 void
 setup_lookup(dig_lookup_t *lookup) {
        isc_result_t result;
+       isc_uint32_t id;
        int len;
        dig_server_t *serv;
        dig_query_t *query;
@@ -1397,7 +1392,8 @@ setup_lookup(dig_lookup_t *lookup) {
        trying(store, lookup);
        INSIST(dns_name_isabsolute(lookup->name));
 
-       lookup->sendmsg->id = (unsigned short)(random() & 0xFFFF);
+       isc_random_get(&id);
+       lookup->sendmsg->id = (unsigned short)id & 0xFFFF;
        lookup->sendmsg->opcode = dns_opcode_query;
        lookup->msgcounter = 0;
        /*