From: Baptiste Daroussin Date: Wed, 4 May 2022 14:05:28 +0000 (+0200) Subject: random: use arc4random where available X-Git-Tag: RELEASE_1_4_0a1~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=806b3da3ddffce028a6cecbd5a452d758f8016e6;p=thirdparty%2Fmlmmj.git random: use arc4random where available --- diff --git a/configure.ac b/configure.ac index 58a02cce..a7289af3 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,7 @@ AM_CONDITIONAL(WANT_RECEIVESTRIP, test x"$enable_receive_strip" = xyes) AC_FUNC_MALLOC AC_CHECK_FUNCS([ftruncate memset socket strerror strncasecmp snprintf fcntl]) AC_CHECK_FUNCS([nanosleep time strftime syslog regcomp regexec]) +AC_CHECK_FUNCS([arc4random_uniform]) AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([src/Makefile]) diff --git a/src/random-int.c b/src/random-int.c index de143816..a0d0770f 100644 --- a/src/random-int.c +++ b/src/random-int.c @@ -30,6 +30,7 @@ int random_int() { +#ifndef HAVE_ARC4RANDOM_UNIFORM static int init = 0; unsigned int seed; int devrandom; @@ -59,6 +60,9 @@ int random_int() init = 1; return rand(); +#else + return arc4random_uniform(INT_MAX); +#endif } #if 0 int main(int argc, char **argv)