diff options
| author | Taylor Brandstetter <deadbeef@google.com> | 2020-10-01 16:09:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-02 01:09:22 +0200 |
| commit | efc9b60ebce08c6e1703d205a09493d8ee9d176a (patch) | |
| tree | a2c67af8f6367cca3a81ef2a090c1f7222c6d40b | |
| parent | cab8a96153ff9353a99786bcc0b228a2a70abcb5 (diff) | |
Call getrandom via syscall directly on Linux. (#533)
Doing this because getrandom wasn't added to glibc until 2.25.
| -rwxr-xr-x | usrsctplib/user_environment.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usrsctplib/user_environment.c b/usrsctplib/user_environment.c index ce96d72..8fbfdcf 100755 --- a/usrsctplib/user_environment.c +++ b/usrsctplib/user_environment.c @@ -206,7 +206,8 @@ finish_random(void) } #endif #elif defined(__linux__) -#include <sys/random.h> +#include <unistd.h> +#include <sys/syscall.h> void init_random(void) @@ -222,7 +223,8 @@ read_random(void *buf, size_t size) position = 0; while (position < size) { - n = getrandom((char *)buf + position, size - position, 0); + // Using syscall directly because getrandom isn't present in glibc < 2.25. + n = syscall(__NR_getrandom, (char *)buf + position, size - position, 0); if (n > 0) { position += n; } |
