From d8988561c04c0244155309bdf701998b9fb98dd5 Mon Sep 17 00:00:00 2001 From: Greg Steuck Date: Fri, 30 Nov 2018 11:55:51 -0800 Subject: openbsd: repair pkg/csource_test --- executor/common_bsd.h | 93 +++++++++++++++++++++++-------------------------- executor/executor_bsd.h | 5 --- 2 files changed, 44 insertions(+), 54 deletions(-) (limited to 'executor') diff --git a/executor/common_bsd.h b/executor/common_bsd.h index a7fc5c8f5..be9fa4029 100644 --- a/executor/common_bsd.h +++ b/executor/common_bsd.h @@ -11,6 +11,50 @@ #if GOOS_openbsd +#define __syscall syscall + +#if SYZ_EXECUTOR || __NR_syz_open_pts + +#include +#include + +static uintptr_t syz_open_pts(void) +{ + int master, slave; + + if (openpty(&master, &slave, NULL, NULL, NULL) == -1) + return -1; + // Move the master fd up in order to reduce the chances of the fuzzer + // generating a call to close(2) with the same fd. + if (dup2(master, master + 100) != -1) + close(master); + return slave; +} + +#endif // SYZ_EXECUTOR || __NR_syz_open_pts + +#if SYZ_EXECUTOR || SYZ_TUN_ENABLE + +#include +#include +#include + +static int tunfd = -1; + +// We just need this to be large enough to hold headers that we parse (ethernet/ip/tcp). +// Rest of the packet (if any) will be silently truncated which is fine. +#define SYZ_TUN_MAX_PACKET_SIZE 1000 + +// Maximum number of tun devices in the default install. +#define MAX_TUN 4 + +// All patterns are non-expanding given values < MAX_TUN. +#define TUN_IFACE "tap%d" +#define TUN_DEVICE "/dev/tap%d" + +#define LOCAL_IPV4 "172.20.%d.170" +#define LOCAL_IPV6 "fe80::%02hxaa" + static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv; @@ -56,55 +100,6 @@ static void execute_command(bool panic, const char* format, ...) } } -#define __syscall syscall - -#if SYZ_EXECUTOR || __NR_syz_open_pts - -#if defined(__OpenBSD__) -#include -#include -#else -// Needed when compiling on Linux. -#include -#endif // defined(__OpenBSD__) - -static uintptr_t syz_open_pts(void) -{ - int master, slave; - - if (openpty(&master, &slave, NULL, NULL, NULL) == -1) - return -1; - // Move the master fd up in order to reduce the chances of the fuzzer - // generating a call to close(2) with the same fd. - if (dup2(master, master + 100) != -1) - close(master); - return slave; -} - -#endif // SYZ_EXECUTOR || __NR_syz_open_pts - -#if SYZ_EXECUTOR || SYZ_TUN_ENABLE - -#include -#include -#include - -static int tunfd = -1; - -// We just need this to be large enough to hold headers that we parse (ethernet/ip/tcp). -// Rest of the packet (if any) will be silently truncated which is fine. -#define SYZ_TUN_MAX_PACKET_SIZE 1000 - -// Maximum number of tun devices in the default install. -#define MAX_TUN 4 - -// All patterns are non-expanding given values < MAX_TUN. -#define TUN_IFACE "tap%d" -#define TUN_DEVICE "/dev/tap%d" - -#define LOCAL_IPV4 "172.20.%d.170" -#define LOCAL_IPV6 "fe80::%02hxaa" - static void initialize_tun(int tun_id) { #if SYZ_EXECUTOR diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h index 3612e2569..7119a3992 100644 --- a/executor/executor_bsd.h +++ b/executor/executor_bsd.h @@ -10,11 +10,6 @@ #include #include -#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) -// This is just so that "make executor TARGETOS=freebsd/netbsd" works on linux. -#define __syscall syscall -#endif - static void os_init(int argc, char** argv, void* data, size_t data_size) { #if GOOS_openbsd -- cgit mrf-deployment