From b2c70855a7b05f207f38f4bdd58fe6600bef9ec9 Mon Sep 17 00:00:00 2001 From: William Ahern Date: Wed, 19 Oct 2016 13:48:01 -0700 Subject: unbreak BSDs by using arc4random_buf --- config.h.guess | 7 +++++++ src/openssl.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config.h.guess b/config.h.guess index c40f6bf..9b5fcdc 100644 --- a/config.h.guess +++ b/config.h.guess @@ -657,6 +657,13 @@ #define HAVE_ARC4RANDOM_ADDRANDOM (HAVE_ARC4RANDOM && !AG_OPENBSD_PREREQ(5,5)) #endif +#ifndef HAVE_ARC4RANDOM_BUF +#define HAVE_ARC4RANDOM_BUF_APPLE_ (!__APPLE__ || AG_MACOS_PREREQ(10,7,0) || AG_IPHONE_PREREQ(4,3)) +#define HAVE_ARC4RANDOM_BUF_NETBSD_ (!__NetBSD__ || AG_NETBSD_PREREQ(6,0,0)) +#define HAVE_ARC4RANDOM_BUF_IFF_ (HAVE_ARC4RANDOM_BUF_APPLE_ && HAVE_ARC4RANDOM_BUF_NETBSD_) +#define HAVE_ARC4RANDOM_BUF (HAVE_ARC4RANDOM && HAVE_ARC4RANDOM_BUF_IFF_) +#endif + #ifndef HAVE_ARC4RANDOM_STIR #define HAVE_ARC4RANDOM_STIR HAVE_ARC4RANDOM_ADDRANDOM #endif diff --git a/src/openssl.c b/src/openssl.c index 78dbd65..88561aa 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -7824,11 +7824,11 @@ static int randL_stir(struct randL_state *st, unsigned rqstd) { int error; unsigned char data[256]; -#if HAVE_ARC4RANDOM +#if HAVE_ARC4RANDOM_BUF while (count < rqstd) { size_t n = MIN(rqstd - count, sizeof data); - arc4random(data, n); + arc4random_buf(data, n); RAND_seed(data, n); -- cgit v1.2.3-59-g8ed1b