summaryrefslogtreecommitdiff
path: root/openbsd-compat/arc4random.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2022-11-01 19:10:30 +1100
committerDarren Tucker <dtucker@dtucker.net>2022-11-02 12:20:50 +1100
commitda6038bd5cd55eb212eb2aec1fc8ae79bbf76156 (patch)
tree0be5b5fd8106a45c789a9a474c639d4cc2432b4e /openbsd-compat/arc4random.c
parent5ebe18cab6be3247b44c807ac145164010465b82 (diff)
downloadopenssh-git-da6038bd5cd55eb212eb2aec1fc8ae79bbf76156.tar.gz
Always use compat getentropy.
Have it call native getentropy and fall back as required. Should fix issues of platforms where libc has getentropy but it is not implemented in the kernel. Based on github PR#354 from simsergey.
Diffstat (limited to 'openbsd-compat/arc4random.c')
-rw-r--r--openbsd-compat/arc4random.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/openbsd-compat/arc4random.c b/openbsd-compat/arc4random.c
index 02f15f9c..ffd33734 100644
--- a/openbsd-compat/arc4random.c
+++ b/openbsd-compat/arc4random.c
@@ -44,13 +44,15 @@
#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.
+ * Always use the getentropy implementation from bsd-getentropy.c, which
+ * will call a native getentropy if available then fall back as required.
+ * We use a different name so that OpenSSL cannot call the wrong getentropy.
*/
-#ifndef HAVE_GETENTROPY
-# define getentropy(x, y) (_ssh_compat_getentropy((x), (y)))
+int _ssh_compat_getentropy(void *, size_t);
+#ifdef getentropy
+# undef getentropy
#endif
+#define getentropy(x, y) (_ssh_compat_getentropy((x), (y)))
#include "log.h"