arc4random() and associated functions can be found in libbsd on GNU/Linux systems.
Signed-off-by: Matthieu Herrb <matthieu.he...@laas.fr> --- configure.ac | 3 ++- src/iceauth.c | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git configure.ac configure.ac index 81809ce..701b6c8 100644 --- configure.ac +++ configure.ac @@ -37,7 +37,8 @@ XTRANS_CONNECTION_FLAGS AC_DEFINE(ICE_t, 1, [Xtrans transport type]) # Checks for library functions. -AC_CHECK_FUNCS([asprintf]) +AC_CHECK_LIB([bsd], [arc4random_buf]) +AC_CHECK_FUNCS([asprintf arc4random_buf]) # Allow checking code with lint, sparse, etc. XORG_WITH_LINT diff --git src/iceauth.c src/iceauth.c index f4d9f36..b125ddf 100644 --- src/iceauth.c +++ src/iceauth.c @@ -36,6 +36,10 @@ Author: Ralph Mor, X Consortium #include <time.h> #define Time_t time_t +#ifdef HAVE_LIBBSD +#include <bsd/stdlib.h> /* for arc4random_buf() */ +#endif + static int was_called_state; /* @@ -58,6 +62,9 @@ IceGenerateMagicCookie ( if ((auth = malloc (len + 1)) == NULL) return (NULL); +#ifdef HAVE_ARC4RANDOM_BUF + arc4random_buf(auth, len); +#else #ifdef ITIMER_REAL { struct timeval now; @@ -79,8 +86,8 @@ IceGenerateMagicCookie ( value = rand (); auth[i] = value & 0xff; } +#endif auth[len] = '\0'; - return (auth); } -- 1.8.3.1 _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel