summaryrefslogtreecommitdiffstats
path: root/regress/lib/libc
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-10-21 16:26:28 +0000
committerkettenis <kettenis@openbsd.org>2020-10-21 16:26:28 +0000
commitfbbf5ad76089d17e724882d95917c0ac87bfd9bd (patch)
tree9bcd4f7799486da66961ae3cc23555311d6f9bd1 /regress/lib/libc
parentProvide dummy definitions for NET_LOCK() and PF_LOCK() when compiling this (diff)
downloadwireguard-openbsd-fbbf5ad76089d17e724882d95917c0ac87bfd9bd.tar.xz
wireguard-openbsd-fbbf5ad76089d17e724882d95917c0ac87bfd9bd.zip
On machines with a userland timecounter we bypass the gettimeofday(2)
syscall. So whenever we pass a bad address we get a SIGSEGV instead of EFAULT. POSIX explicitly allows this behaviour. So adjust the test to deal with this case. ok deraadt@, millert@, guenther@
Diffstat (limited to 'regress/lib/libc')
-rw-r--r--regress/lib/libc/sys/t_gettimeofday.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/regress/lib/libc/sys/t_gettimeofday.c b/regress/lib/libc/sys/t_gettimeofday.c
index de768b023ae..ec4a72c63e5 100644
--- a/regress/lib/libc/sys/t_gettimeofday.c
+++ b/regress/lib/libc/sys/t_gettimeofday.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: t_gettimeofday.c,v 1.1.1.1 2019/11/19 19:57:03 bluhm Exp $ */
+/* $OpenBSD: t_gettimeofday.c,v 1.2 2020/10/21 16:26:28 kettenis Exp $ */
/* $NetBSD: t_gettimeofday.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $ */
/*-
@@ -41,6 +41,14 @@ __RCSID("$NetBSD: t_gettimeofday.c,v 1.1 2011/07/07 06:57:53 jruoho Exp $");
#include <errno.h>
#include <string.h>
+static void sighandler(int);
+
+static void
+sighandler(int signo)
+{
+ _exit(0);
+}
+
ATF_TC(gettimeofday_err);
ATF_TC_HEAD(gettimeofday_err, tc)
{
@@ -50,8 +58,14 @@ ATF_TC_HEAD(gettimeofday_err, tc)
ATF_TC_BODY(gettimeofday_err, tc)
{
- errno = 0;
+ /*
+ * With userland timecounters we will generate SIGSEGV instead
+ * of failing with errno so to EFAULT. POSIX explicitly
+ * allows this behaviour.
+ */
+ ATF_REQUIRE(signal(SIGSEGV, sighandler) != SIG_ERR);
+ errno = 0;
ATF_REQUIRE_ERRNO(EFAULT, gettimeofday((void *)-1, NULL) != 0);
}