The branch master has been updated via 7421f085005e0d7a1dd2fe61b991ff23cef91c22 (commit) via 0c27ce7322e15a7e0733d48aaf9c8e1d1249541f (commit) via e2e4b784e65eaafb133a7db3d344446c43112d41 (commit) from e4ec769eb9a18df3593339fc1213dc9441155c90 (commit)
- Log ----------------------------------------------------------------- commit 7421f085005e0d7a1dd2fe61b991ff23cef91c22 Author: nia <n...@netbsd.org> Date: Thu Apr 30 14:43:04 2020 +0100 rand_unix.c: Ensure requests to KERN_ARND don't exceed 256 bytes. Requests for more than 256 bytes will fail. Reviewed-by: Paul Dale <paul.d...@oracle.com> Reviewed-by: Matt Caswell <m...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11689) commit 0c27ce7322e15a7e0733d48aaf9c8e1d1249541f Author: nia <n...@netbsd.org> Date: Thu Apr 30 14:42:09 2020 +0100 rand_unix.c: Only enable hack for old FreeBSD versions on FreeBSD Reviewed-by: Paul Dale <paul.d...@oracle.com> Reviewed-by: Matt Caswell <m...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11689) commit e2e4b784e65eaafb133a7db3d344446c43112d41 Author: nia <n...@netbsd.org> Date: Thu Apr 30 14:41:07 2020 +0100 rand_unix.c: Include correct headers for sysctl() on NetBSD This allows sysctl(KERN_ARND) to be detected properly. Reviewed-by: Paul Dale <paul.d...@oracle.com> Reviewed-by: Matt Caswell <m...@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11689) ----------------------------------------------------------------------- Summary of changes: crypto/rand/rand_unix.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index 319c6e4c53..081ffca908 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -27,12 +27,12 @@ # include <sys/utsname.h> # endif #endif -#if defined(__FreeBSD__) && !defined(OPENSSL_SYS_UEFI) +#if (defined(__FreeBSD__) || defined(__NetBSD__)) && !defined(OPENSSL_SYS_UEFI) # include <sys/types.h> # include <sys/sysctl.h> # include <sys/param.h> #endif -#if defined(__OpenBSD__) || defined(__NetBSD__) +#if defined(__OpenBSD__) # include <sys/param.h> #endif @@ -227,10 +227,12 @@ static ssize_t sysctl_random(char *buf, size_t buflen) * when the sysctl returns long and we want to request something not a * multiple of longs, which should never be the case. */ +#if defined(__FreeBSD__) if (!ossl_assert(buflen % sizeof(long) == 0)) { errno = EINVAL; return -1; } +#endif /* * On NetBSD before 4.0 KERN_ARND was an alias for KERN_URND, and only @@ -248,7 +250,7 @@ static ssize_t sysctl_random(char *buf, size_t buflen) mib[1] = KERN_ARND; do { - len = buflen; + len = buflen > 256 ? 256 : buflen; if (sysctl(mib, 2, buf, &len, NULL, 0) == -1) return done > 0 ? done : -1; done += len;