Unbreak build of afl-forkserver.c on *BSD
#include <sys/wait.h>
#include <sys/resource.h>
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#define HAVE_ARC4RANDOM 1
+#endif /* __APPLE__ || __FreeBSD__ || __OpenBSD__ */
+
/* a program that includes afl-forkserver needs to define these */
extern u8 uses_asan;
extern u8 *trace_bits;
extern s32 forksrv_pid, child_pid, fsrv_ctl_fd, fsrv_st_fd;
-extern s32 out_fd, out_dir_fd, dev_urandom_fd,
- dev_null_fd; /* initialize these with -1 */
+extern s32 out_fd, out_dir_fd, dev_null_fd; /* initialize these with -1 */
+#ifndef HAVE_ARC4RANDOM
+extern s32 dev_random_fd;
+#endif
extern u32 exec_tmout;
extern u64 mem_limit;
extern u8 * out_file, *target_path, *doc_path;
@@ -232,7 +238,9 @@ void init_forkserver(char **argv) {
close(out_dir_fd);
close(dev_null_fd);
+#ifndef HAVE_ARC4RANDOM
close(dev_urandom_fd);
+#endif
close(plot_file == NULL ? -1 : fileno(plot_file));
/* This should improve performance a bit, since it stops the linker from
