From 74222fc0963fece65e1f31524f209c00ce8941bc Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 28 Dec 2013 01:35:01 +0000 Subject: [PATCH] Ouch. --- src/util.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/util.c b/src/util.c index db7529a92..776e807d1 100644 --- a/src/util.c +++ b/src/util.c @@ -2401,7 +2401,6 @@ rspamd_random_bytes (gchar *buf, gsize buflen) { gint fd; gsize i; - time_t t; #ifdef HAVE_OPENSSL /* Init random generator */ @@ -2426,12 +2425,9 @@ fallback: close (fd); } /* No /dev/random */ - for (i = 0; i < buflen;) { - /* Place least significant byte to the beginning */ - t = time (NULL); - t = GLONG_TO_BE (t); - memcpy (&buf[i], &t, MIN (sizeof (t), buflen - i)); - i += sizeof (t); + g_random_set_seed (time (NULL)); + for (i = 0; i < buflen; i ++) { + buf[i] = g_random_int () & 0xff; } } -- 2.39.5