summaryrefslogtreecommitdiff
path: root/regress/lib/libc
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2014-07-09 23:54:01 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2014-07-09 23:54:01 +0000
commit69b05c81767360510212f66ff748a3cbc61c5268 (patch)
tree002411b009fc65b1d0b36154a519835ab2798ff3 /regress/lib/libc
parent4cc85869f1e344d1d7205e9705c6445ad9db015d (diff)
Add some extra sanity checks to make sure the test functions actually
run on altstack.
Diffstat (limited to 'regress/lib/libc')
-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));
}