]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Rename our getentropy to prevent possible loops.
authorDarren Tucker <dtucker@dtucker.net>
Wed, 10 Aug 2022 07:25:24 +0000 (17:25 +1000)
committerDarren Tucker <dtucker@dtucker.net>
Wed, 10 Aug 2022 07:36:44 +0000 (17:36 +1000)
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@

openbsd-compat/arc4random.c
openbsd-compat/bsd-getentropy.c
openbsd-compat/openbsd-compat.h

index f43b5c7cc2db6819d0e152e24fdbd99d67b421c0..2f91c2b2bfdf65ba4ba651bcf1f3bffe234458ed 100644 (file)
 
 #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))
 
 #include "log.h"
index 1733e2873cd9b503ae4c2c460136daaf21aec0c4..bd4b6695acc6f038a435801c6dd902f77eee6596 100644 (file)
@@ -41,7 +41,7 @@
 #include "log.h"
 
 int
-getentropy(void *s, size_t len)
+_ssh_compat_getentropy(void *s, size_t len)
 {
 #ifdef WITH_OPENSSL
        if (RAND_bytes(s, len) <= 0)
index 1835a9a54543a9dbaf651726312705460100afdb..3e2ebb60ac2a23ee59425197c00076c3265b8510 100644 (file)
@@ -70,7 +70,7 @@ int ftruncate(int filedes, off_t length);
 #endif
 
 #if defined(HAVE_DECL_GETENTROPY) && HAVE_DECL_GETENTROPY == 0
-int getentropy(void *, size_t);
+int _ssh_compat_getentropy(void *, size_t);
 #endif
 
 #ifndef HAVE_GETLINE