From: Vsevolod Stakhov Date: Sat, 28 Dec 2013 01:35:01 +0000 (+0000) Subject: Ouch. X-Git-Tag: 0.6.7~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74222fc0963fece65e1f31524f209c00ce8941bc;p=thirdparty%2Frspamd.git Ouch. --- diff --git a/src/util.c b/src/util.c index db7529a920..776e807d17 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; } }