Browse Source

[core] compile fix for Mac OS X 10.6 (old) (fixes #2773)

Mac OS X 10.7 Lion introduces arc4random_buf()

(thx ryandesign)

x-ref:
  "Mac OS X build issue Undefined symbols"
  https://redmine.lighttpd.net/issues/2773
personal/stbuehler/mod-csrf
Glenn Strauss 5 years ago
parent
commit
df61f19daf
  1. 2
      SConstruct
  2. 2
      configure.ac
  3. 2
      src/CMakeLists.txt
  4. 4
      src/rand.c

2
SConstruct

@ -221,7 +221,7 @@ if 1:
getuid select signal pathconf madvise prctl\
writev sigaction sendfile64 send_file kqueue port_create localtime_r posix_fadvise issetugid inet_pton \
memset_s explicit_bzero clock_gettime \
getentropy arc4random jrand48 srandom getloadavg'))
getentropy arc4random_buf jrand48 srandom getloadavg'))
checkFunc(autoconf, 'getrandom', 'linux/random.h')
checkTypes(autoconf, Split('pid_t size_t off_t'))

2
configure.ac

@ -773,7 +773,7 @@ AC_CHECK_FUNCS([dup2 getcwd inet_ntoa inet_ntop inet_pton issetugid memset mmap
getuid select signal pathconf madvise posix_fadvise posix_madvise \
writev sigaction sendfile64 send_file kqueue port_create localtime_r gmtime_r \
memset_s explicit_bzero clock_gettime \
getentropy arc4random jrand48 srandom getloadavg])
getentropy arc4random_buf jrand48 srandom getloadavg])
AC_CHECK_HEADERS([linux/random.h],[
AC_CHECK_FUNC([getrandom], AC_DEFINE([HAVE_GETRANDOM], [1], [getrandom]))
])

2
src/CMakeLists.txt

@ -129,7 +129,7 @@ set(CMAKE_EXTRA_INCLUDE_FILES)
check_type_size(long SIZEOF_LONG)
check_type_size(off_t SIZEOF_OFF_T)
check_function_exists(arc4random HAVE_ARC4RANDOM)
check_function_exists(arc4random_buf HAVE_ARC4RANDOM_BUF)
check_function_exists(chroot HAVE_CHROOT)
check_function_exists(epoll_ctl HAVE_EPOLL_CTL)
check_function_exists(fork HAVE_FORK)

4
src/rand.c

@ -125,7 +125,7 @@ void li_rand_reseed (void)
u = ((unsigned int)xsubi[0] << 16) | xsubi[1];
}
else {
#ifdef HAVE_ARC4RANDOM
#ifdef HAVE_ARC4RANDOM_BUF
u = arc4random();
arc4random_buf(xsubi, sizeof(xsubi));
#else
@ -155,7 +155,7 @@ int li_rand (void)
int i;
if (-1 != RAND_pseudo_bytes((unsigned char *)&i, sizeof(i))) return i;
#endif
#ifdef HAVE_ARC4RANDOM
#ifdef HAVE_ARC4RANDOM_BUF
return (int)arc4random();
#elif defined(HAVE_SRANDOM)
/* coverity[dont_call : FALSE] */

Loading…
Cancel
Save