From 71dde7c4f832d34f44015285e01b1b1e3fea868e Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 24 Aug 2018 18:44:49 -0400 Subject: [PATCH] provide getrandom wrapper to support glibc < 2.25 Debian stretch (currently stable) only has glibc 2.24... --- random.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/random.c b/random.c index 0cbb74d..d3f6f0f 100644 --- a/random.c +++ b/random.c @@ -1,11 +1,21 @@ #include #include -#include - #include "random.h" #include "util.h" +#if __has_include() +// glibc 2.25 and later +#include +#else +#include +#include + +static ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) { + return syscall(SYS_getrandom, buf, buflen, flags); +} +#endif + void get_random_seed(void *buf, size_t size) { while (size > 0) { ssize_t r;