mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-10-01 01:36:01 -04:00
provide getrandom wrapper to support glibc < 2.25
Debian stretch (currently stable) only has glibc 2.24...
This commit is contained in:
parent
35c9e6f16d
commit
71dde7c4f8
14
random.c
14
random.c
@ -1,11 +1,21 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/random.h>
|
||||
|
||||
#include "random.h"
|
||||
#include "util.h"
|
||||
|
||||
#if __has_include(<sys/random.h>)
|
||||
// glibc 2.25 and later
|
||||
#include <sys/random.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user