dovecot-2.2: lib: use new srand() wrapper in lib

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 27 13:22:47 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/14f505c1c6f4
changeset: 17531:14f505c1c6f4
user:      Phil Carmody <phil at dovecot.fi>
date:      Fri Jun 27 16:16:16 2014 +0300
description:
lib: use new srand() wrapper in lib
Of course, multiple seeding calls make it harder to know exactly
what numbers have been generated. But this is better than nothing.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/lib.c     |  2 +-
 src/lib/randgen.c |  4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r f9deece0002f -r 14f505c1c6f4 src/lib/lib.c
--- a/src/lib/lib.c	Fri Jun 27 16:15:24 2014 +0300
+++ b/src/lib/lib.c	Fri Jun 27 16:16:16 2014 +0300
@@ -61,7 +61,7 @@
 	/* standard way to get rand() return different values. */
 	if (gettimeofday(&tv, NULL) < 0)
 		i_fatal("gettimeofday(): %m");
-	srand((unsigned int) (tv.tv_sec ^ tv.tv_usec ^ getpid()));
+	rand_set_seed((unsigned int) (tv.tv_sec ^ tv.tv_usec ^ getpid()));
 
 	data_stack_init();
 	hostpid_init();
diff -r f9deece0002f -r 14f505c1c6f4 src/lib/randgen.c
--- a/src/lib/randgen.c	Fri Jun 27 16:15:24 2014 +0300
+++ b/src/lib/randgen.c	Fri Jun 27 16:16:16 2014 +0300
@@ -53,7 +53,7 @@
 	}
 
 	random_fill(&seed, sizeof(seed));
-	srand(seed);
+	rand_set_seed(seed);
 
 	fd_close_on_exec(urandom_fd, TRUE);
 }
@@ -102,7 +102,7 @@
 	}
 
 	random_fill(&seed, sizeof(seed));
-	srand(seed);
+	rand_set_seed(seed);
 }
 
 void random_deinit(void) {}


More information about the dovecot-cvs mailing list