diff options
author | Yann Ylavic <ylavic@apache.org> | 2018-06-01 13:53:50 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2018-06-01 13:53:50 +0000 |
commit | 6a7174da2feb5e873b5ca1bed2e1cb148fc93d96 (patch) | |
tree | 0ab8d8421994456626d3f345882c312d7005915a /misc | |
parent | 8e030814013323e9ae3ef2087769ef6cf66fda6a (diff) | |
download | apr-6a7174da2feb5e873b5ca1bed2e1cb148fc93d96.tar.gz |
rand: follow up to r1814240: still honor --with-devrandom if specified.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1832691 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc')
-rw-r--r-- | misc/unix/rand.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/misc/unix/rand.c b/misc/unix/rand.c index 5e2359901..c0567a667 100644 --- a/misc/unix/rand.c +++ b/misc/unix/rand.c @@ -43,6 +43,7 @@ #include <sys/uuid.h> #endif +#if defined(SYS_RANDOM) #if defined(HAVE_SYS_RANDOM_H) && \ defined(HAVE_GETRANDOM) @@ -60,12 +61,12 @@ #include <unistd.h> #include <sys/syscall.h> #include <linux/random.h> - #define getrandom(buf, buflen, flags) \ syscall(SYS_getrandom, (buf), (buflen), (flags)) #define USE_GETRANDOM #endif /* HAVE_SYS_RANDOM_H */ +#endif /* SYS_RANDOM */ #ifndef SHUT_RDWR #define SHUT_RDWR 2 @@ -207,12 +208,12 @@ APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, return bad_errno; } -#elif defined(USE_GETRANDOM) +#elif defined(SYS_RANDOM) && defined(USE_GETRANDOM) do { int rc; - rc = getrandom(buf, length, GRND_NONBLOCK); + rc = getrandom(buf, length, 0); if (rc == -1) { if (errno == EINTR) { continue; @@ -224,7 +225,7 @@ APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, length -= rc; } while (length > 0); -#elif defined(HAVE_ARC4RANDOM_BUF) +#elif defined(SYS_RANDOM) && defined(HAVE_ARC4RANDOM_BUF) arc4random_buf(buf, length); |