From cefe9907fd0ac1656db1e6f5d4cec8efdba40907 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 19 Jan 2015 05:26:01 -0600 Subject: [PATCH] correct arc4random/arc4random_uniform checks reported by Loganaden Velvindron --- configure.ac | 6 ++++-- include/stdlib.h | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b500c7d..16acbe1 100644 --- a/configure.ac +++ b/configure.ac @@ -97,7 +97,7 @@ LDFLAGS="$LDFLAGS $CLANG_FLAGS" # check functions that are expected to be in libc AC_CHECK_FUNCS([adjfreq ntp_adjtime adjtimex]) -AC_CHECK_FUNCS([arc4random_uniform asprintf explicit_bzero]) +AC_CHECK_FUNCS([arc4random arc4random_uniform asprintf explicit_bzero]) AC_CHECK_FUNCS([getentropy memmem poll reallocarray]) AC_CHECK_FUNCS([setproctitle setgroups]) AC_CHECK_FUNCS([setregid setresgid setreuid setresuid]) @@ -137,9 +137,11 @@ AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes]) AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes]) -# overrides for arc4random_buf implementations with known issues +# overrides for arc4random implementations with known issues AM_CONDITIONAL([HAVE_ARC4RANDOM], [test "x$HOST_OS" != xdarwin -a "x$HOST_OS" != xfreebsd -a "x$ac_cv_func_arc4random" = xyes]) +AM_CONDITIONAL([HAVE_ARC4RANDOM_UNIFORM], + [test "x$HOST_OS" != xdarwin -a "x$HOST_OS" != xfreebsd -a "x$ac_cv_func_arc4random_uniform" = xyes]) AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[ diff --git a/include/stdlib.h b/include/stdlib.h index b3b656e..2c1fa2c 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -12,8 +12,11 @@ #include #include -#ifndef HAVE_ARC4RANDOM_BUF +#ifndef HAVE_ARC4RANDOM_ uint32_t arc4random(void); +#endif + +#ifndef HAVE_ARC4RANDOM_UNIFORM uint32_t arc4random_uniform(uint32_t); #endif