Start using arc4random_buf with BSD and libbsd

This commit is contained in:
Sebastian Pipping 2017-05-25 18:21:57 +02:00
parent c9cc7dd3d7
commit 7a93938687
3 changed files with 26 additions and 2 deletions

View File

@ -124,7 +124,7 @@ LTFLAGS = --verbose
COMPILE = $(CC) $(INCLUDES) $(CFLAGS) $(DEFS) $(CPPFLAGS)
CXXCOMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) $(DEFS) $(CPPFLAGS)
LTCOMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE)
LINK_LIB = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) -no-undefined $(VSNFLAG) -rpath $(libdir) $(LDFLAGS) -o $@
LINK_LIB = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) -no-undefined $(VSNFLAG) -rpath $(libdir) $(LDFLAGS) @LIBS@ -o $@
LINK_EXE = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) $(LDFLAGS) -o $@
LINK_CXX_EXE = $(LIBTOOL) $(LTFLAGS) --mode=link $(CXXCOMPILE) $(LDFLAGS) -o $@

View File

@ -100,6 +100,26 @@ AC_TYPE_SIZE_T
AC_CHECK_FUNCS(memmove bcopy)
AC_CHECK_LIB([bsd], [arc4random_buf])
AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <stdlib.h> /* for arc4random_buf on BSD, for NULL */
#if defined(HAVE_LIBBSD)
# include <bsd/stdlib.h>
#endif
int main() {
arc4random_buf(NULL, 0U);
return 0;
}
])], [
AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1],
[Define to 1 if you have the `arc4random_buf' function.])
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <stdlib.h> /* for NULL */

View File

@ -779,6 +779,10 @@ gather_time_entropy(void)
#endif
}
#if defined(HAVE_ARC4RANDOM_BUF) && defined(HAVE_LIBBSD)
# include <bsd/stdlib.h>
#endif
static unsigned long
generate_hash_secret_salt(XML_Parser parser)
{
@ -790,7 +794,7 @@ generate_hash_secret_salt(XML_Parser parser)
# define PARSER_CAST(p) (p)
#endif
#ifdef __CloudABI__
#if defined(HAVE_ARC4RANDOM_BUF) || defined(__CloudABI__)
unsigned long entropy;
(void)parser;
(void)gather_time_entropy;