mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-30 01:05:14 +02:00
Rename our getentropy to prevent possible loops.
Since arc4random seeds from getentropy, and we use OpenSSL for that if enabled, there's the possibility that if we build on a system that does not have getentropy then run on a system that does have it, then OpenSSL could end up calling our getentropy and getting stuck in a loop. Pointed out by deraadt@, ok djm@
This commit is contained in:
parent
7a01f61be8
commit
7e2f51940b
@ -35,6 +35,15 @@
|
|||||||
|
|
||||||
#ifndef HAVE_ARC4RANDOM
|
#ifndef HAVE_ARC4RANDOM
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we're not using a native getentropy, use the one from bsd-getentropy.c
|
||||||
|
* under a different name, so that if in future these binaries are run on
|
||||||
|
* a system that has a native getentropy OpenSSL cannot call the wrong one.
|
||||||
|
*/
|
||||||
|
#ifndef HAVE_GETENTROPY
|
||||||
|
# define getentropy(x, y) (_ssh_compat_getentropy((x), (y)))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
|
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
getentropy(void *s, size_t len)
|
_ssh_compat_getentropy(void *s, size_t len)
|
||||||
{
|
{
|
||||||
#ifdef WITH_OPENSSL
|
#ifdef WITH_OPENSSL
|
||||||
if (RAND_bytes(s, len) <= 0)
|
if (RAND_bytes(s, len) <= 0)
|
||||||
|
@ -70,7 +70,7 @@ int ftruncate(int filedes, off_t length);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DECL_GETENTROPY) && HAVE_DECL_GETENTROPY == 0
|
#if defined(HAVE_DECL_GETENTROPY) && HAVE_DECL_GETENTROPY == 0
|
||||||
int getentropy(void *, size_t);
|
int _ssh_compat_getentropy(void *, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_GETLINE
|
#ifndef HAVE_GETLINE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user