summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew@openbsd.org>2014-07-09 23:54:00 +0000
committermatthew <matthew@openbsd.org>2014-07-09 23:54:00 +0000
commit6211cbf539ec9e3e51626f120fd6507e7cbf2094 (patch)
treeaf15f0baeee09e0b1ed445ac408083cc235544e0
parentinclude <limits.h> for LONG_MIN/LONG_MAX. (diff)
downloadwireguard-openbsd-6211cbf539ec9e3e51626f120fd6507e7cbf2094.tar.xz
wireguard-openbsd-6211cbf539ec9e3e51626f120fd6507e7cbf2094.zip
Add some extra sanity checks to make sure the test functions actually
run on altstack.
-rw-r--r--regress/lib/libc/explicit_bzero/explicit_bzero.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/regress/lib/libc/explicit_bzero/explicit_bzero.c b/regress/lib/libc/explicit_bzero/explicit_bzero.c
index 658d2f1e51a..d1e4d1494e4 100644
--- a/regress/lib/libc/explicit_bzero/explicit_bzero.c
+++ b/regress/lib/libc/explicit_bzero/explicit_bzero.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: explicit_bzero.c,v 1.3 2014/07/09 18:02:24 matthew Exp $ */
+/* $OpenBSD: explicit_bzero.c,v 1.4 2014/07/09 23:54:00 matthew Exp $ */
/*
* Copyright (c) 2014 Google Inc.
*
@@ -39,6 +39,14 @@ setup_stack(void)
}
static void
+assert_on_stack(void)
+{
+ stack_t cursigstk;
+ ASSERT_EQ(0, sigaltstack(NULL, &cursigstk));
+ ASSERT_EQ(SS_ONSTACK, cursigstk.ss_flags & (SS_DISABLE|SS_ONSTACK));
+}
+
+static void
call_on_stack(void (*fn)(int))
{
/*
@@ -106,14 +114,18 @@ static void
test_without_bzero(int signo)
{
char buf[SECRETBYTES];
+ assert_on_stack();
populate_secret(buf, sizeof(buf));
+ ASSERT_NE(NULL, memmem(altstack, sizeof(altstack), buf, sizeof(buf)));
}
static void
test_with_bzero(int signo)
{
char buf[SECRETBYTES];
+ assert_on_stack();
populate_secret(buf, sizeof(buf));
+ ASSERT_NE(NULL, memmem(altstack, sizeof(altstack), buf, sizeof(buf)));
explicit_bzero(buf, sizeof(buf));
}