aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_bsd.h
diff options
context:
space:
mode:
Diffstat (limited to 'executor/common_bsd.h')
-rw-r--r--executor/common_bsd.h31
1 files changed, 31 insertions, 0 deletions
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 <termios.h>
+#include <util.h>
+#else
+// Needed when compiling on Linux.
+#include <pty.h>
+#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