]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1499. [bug] isc_random need to be seeded better if arc4random()
authorMark Andrews <marka@isc.org>
Tue, 5 Aug 2003 00:08:30 +0000 (00:08 +0000)
committerMark Andrews <marka@isc.org>
Tue, 5 Aug 2003 00:08:30 +0000 (00:08 +0000)
                        is not used.

CHANGES
lib/isc/random.c

diff --git a/CHANGES b/CHANGES
index de32cc250370eb8d7390f8f7993051fe567b87a2..55687d422329d64c95ac9a5a9aae34180611a55a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+1499.  [bug]           isc_random need to be seeded better if arc4random()
+                       is not used.
+
 1498.  [port]          bsdos: 5.x support.
 
 1497.  [placeholder]
index 9091cbf1c35d8cb97ab6ad22696eda2133f070e8..aa495e8348af9f03302650e749a256fb913c8b24 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: random.c,v 1.17 2002/12/05 04:36:26 marka Exp $ */
+/* $Id: random.c,v 1.18 2003/08/05 00:08:30 marka Exp $ */
 
 #include <config.h>
 
@@ -34,7 +34,15 @@ static void
 initialize_rand(void)
 {
 #ifndef HAVE_ARC4RANDOM
-       srand(time(NULL));
+       unsigned int pid = getpid();
+       
+       /*
+        * The low bits of pid generally change faster.
+        * Xor them with the high bits of time which change slowly.
+        */
+       pid = ((pid << 16) & 0xffff0000) | ((pid >> 16) & 0xffff);
+
+       srand(time(NULL) ^ pid);
 #endif
 }