about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2019-12-01 15:26:22 +0100
committerGitHub <noreply@github.com>2019-12-01 15:26:22 +0100
commit8d5fded4d8f0f752ae2a4e2baed04a0c63258216 (patch)
tree59be7ec1f89db0cedecb4fbfd955962aa78b050a
parentd4da9b805afff319da98a40a688b8afa3b328cec (diff)
parent8e85b9cbf36ffc63fd740d360d02e8ba9fc69cab (diff)
downloadafl++-8d5fded4d8f0f752ae2a4e2baed04a0c63258216.tar.gz
Merge pull request #124 from devnexen/old_linux_libdislocator_build_fix
getrandom available only from GLIBC 2.25
-rw-r--r--libdislocator/libdislocator.so.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libdislocator/libdislocator.so.c b/libdislocator/libdislocator.so.c
index 0efe679e..9a2ab004 100644
--- a/libdislocator/libdislocator.so.c
+++ b/libdislocator/libdislocator.so.c
@@ -31,10 +31,15 @@
 #endif
 
 #ifdef __linux__
+#if __GLIBC__ >= 2 || __GLIBC_MINOR >= 25
 #define _GNU_SOURCE
 #include <unistd.h>
 #include <sys/syscall.h>
 #define arc4random_buf(p, l) do { ssize_t rd = syscall(__NR_getrandom, p, l, 0); if (rd != l) DEBUGF("getrandom failed"); } while(0)
+#else
+#include <time.h>
+#define arc4random_buf(p, l) do { srand(time(NULL)); u32 i; u8 *ptr = (u8 *)p; for(i = 0; i < l; i++) ptr[i] = rand() % INT_MAX; } while(0)
+#endif
 #endif
 
 #include "config.h"