From 7b75257f75876ae8b1f6a5373a151c9e0633d1e1 Mon Sep 17 00:00:00 2001 From: matthieu Date: Sat, 20 Jul 2013 13:27:38 +0000 Subject: [PATCH] Replace random() with arc4random_buf() --- lib/libXdmcp/Key.c | 4 ++++ lib/libXdmcp/configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/libXdmcp/Key.c b/lib/libXdmcp/Key.c index aa4add653..b1f29b764 100644 --- a/lib/libXdmcp/Key.c +++ b/lib/libXdmcp/Key.c @@ -59,6 +59,7 @@ getbits (long data, unsigned char *dst) void XdmcpGenerateKey (XdmAuthKeyPtr key) { +#ifndef HAVE_ARC4RANDOM_BUF long lowbits, highbits; srandom ((int)getpid() ^ time((Time_t *)0)); @@ -66,6 +67,9 @@ XdmcpGenerateKey (XdmAuthKeyPtr key) highbits = random (); getbits (lowbits, key->data); getbits (highbits, key->data + 4); +#else + arc4random_buf(key->data, 8); +#endif } int diff --git a/lib/libXdmcp/configure.ac b/lib/libXdmcp/configure.ac index 08c046ae0..8b885cab1 100644 --- a/lib/libXdmcp/configure.ac +++ b/lib/libXdmcp/configure.ac @@ -53,7 +53,7 @@ AC_PROG_LN_S AC_SEARCH_LIBS([recvfrom],[socket]) # Checks for library functions. -AC_CHECK_FUNCS([srand48 lrand48]) +AC_CHECK_FUNCS([srand48 lrand48 arc4random_buf]) # Obtain compiler/linker options for depedencies PKG_CHECK_MODULES(XDMCP, xproto)