From b771b17ec95715c24715d730363f6f07bc46fd4f Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Tue, 28 Aug 2018 19:07:26 +0200 Subject: Add mandatory OpenBSD bits (#689) all: add openbsd support squash of the following commits: * openbsd: add mandatory bits * report: add OpenBSD support * executor: skip building kvm on OpenBSD * executor: add OpenBSD support Linking against libutil is necessary due to usage of openpty(3). * executor: fix typo in fail() message * fixup! report: add OpenBSD support * fixup! openbsd: add mandatory bits * fixup! openbsd: add mandatory bits * fixup! openbsd: add mandatory bits * fixup! report: add OpenBSD support * gometalinter: skip sys/openbsd --- executor/common_bsd.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'executor/common_bsd.h') diff --git a/executor/common_bsd.h b/executor/common_bsd.h index b678dd968..004009861 100644 --- a/executor/common_bsd.h +++ b/executor/common_bsd.h @@ -18,3 +18,34 @@ static int do_sandbox_none(void) #define do_sandbox_setuid() 0 #define do_sandbox_namespace() 0 #endif + +#if GOOS_openbsd + +#define __syscall syscall + +#if SYZ_EXECUTOR || __NR_syz_open_pts + +#if defined(__OpenBSD__) +#include +#include +#else +// Needed when compiling on Linux. +#include +#endif + +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 + +#endif -- cgit mrf-deployment