Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-04-10 18:26:04 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-04-10 18:26:04 +0300
commit200a9669fbf6f06894e4243cccc9fc11a1a6073a (patch)
tree68d063899f02dbf640b70aa3191e05a613ab72d9 /miscutils
parent85e4805ae94ce653d8088d6575dc01114cd00bcf (diff)
seedrng: fix for glibc <= 2.24 not providing getrandom()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/seedrng.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/miscutils/seedrng.c b/miscutils/seedrng.c
index 967741dc7..7cc855141 100644
--- a/miscutils/seedrng.c
+++ b/miscutils/seedrng.c
@@ -45,6 +45,20 @@
#include <sys/random.h>
#include <sys/file.h>
+/* Fix up glibc <= 2.24 not having getrandom() */
+#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24
+#include <sys/syscall.h>
+# define getrandom(...) bb_getrandom(__VA_ARGS__)
+static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
+{
+# if defined(__NR_getrandom)
+ return syscall(__NR_getrandom, buffer, length, flags);
+# else
+ return ENOSYS;
+# endif
+}
+#endif
+
#ifndef GRND_INSECURE
#define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this yet. */
#endif