diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-10 17:26:04 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-10 17:26:04 +0200 |
commit | 200a9669fbf6f06894e4243cccc9fc11a1a6073a (patch) | |
tree | 68d063899f02dbf640b70aa3191e05a613ab72d9 /miscutils/seedrng.c | |
parent | 85e4805ae94ce653d8088d6575dc01114cd00bcf (diff) | |
download | busybox-w32-200a9669fbf6f06894e4243cccc9fc11a1a6073a.tar.gz busybox-w32-200a9669fbf6f06894e4243cccc9fc11a1a6073a.tar.bz2 busybox-w32-200a9669fbf6f06894e4243cccc9fc11a1a6073a.zip |
seedrng: fix for glibc <= 2.24 not providing getrandom()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r-- | miscutils/seedrng.c | 14 |
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 @@ | |||
45 | #include <sys/random.h> | 45 | #include <sys/random.h> |
46 | #include <sys/file.h> | 46 | #include <sys/file.h> |
47 | 47 | ||
48 | /* Fix up glibc <= 2.24 not having getrandom() */ | ||
49 | #if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 24 | ||
50 | #include <sys/syscall.h> | ||
51 | # define getrandom(...) bb_getrandom(__VA_ARGS__) | ||
52 | static ssize_t getrandom(void *buffer, size_t length, unsigned flags) | ||
53 | { | ||
54 | # if defined(__NR_getrandom) | ||
55 | return syscall(__NR_getrandom, buffer, length, flags); | ||
56 | # else | ||
57 | return ENOSYS; | ||
58 | # endif | ||
59 | } | ||
60 | #endif | ||
61 | |||
48 | #ifndef GRND_INSECURE | 62 | #ifndef GRND_INSECURE |
49 | #define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this yet. */ | 63 | #define GRND_INSECURE 0x0004 /* Apparently some headers don't ship with this yet. */ |
50 | #endif | 64 | #endif |