summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthew <>2014-07-09 23:54:00 +0000
committermatthew <>2014-07-09 23:54:00 +0000
commitb3742339325c5255c4d028bbe38491007818891d (patch)
tree85579bbae92d59d78c5b5aac14593d58956970fe
parentfcd0a3e52e3cacfd10503ab5f846dfde22677aa5 (diff)
downloadopenbsd-b3742339325c5255c4d028bbe38491007818891d.tar.gz
openbsd-b3742339325c5255c4d028bbe38491007818891d.tar.bz2
openbsd-b3742339325c5255c4d028bbe38491007818891d.zip
Add some extra sanity checks to make sure the test functions actually
run on altstack.
-rw-r--r--src/regress/lib/libc/explicit_bzero/explicit_bzero.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/regress/lib/libc/explicit_bzero/explicit_bzero.c b/src/regress/lib/libc/explicit_bzero/explicit_bzero.c
index 658d2f1e51..d1e4d1494e 100644
--- a/src/regress/lib/libc/explicit_bzero/explicit_bzero.c
+++ b/src/regress/lib/libc/explicit_bzero/explicit_bzero.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: explicit_bzero.c,v 1.3 2014/07/09 18:02:24 matthew Exp $ */ 1/* $OpenBSD: explicit_bzero.c,v 1.4 2014/07/09 23:54:00 matthew Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Google Inc. 3 * Copyright (c) 2014 Google Inc.
4 * 4 *
@@ -39,6 +39,14 @@ setup_stack(void)
39} 39}
40 40
41static void 41static void
42assert_on_stack(void)
43{
44 stack_t cursigstk;
45 ASSERT_EQ(0, sigaltstack(NULL, &cursigstk));
46 ASSERT_EQ(SS_ONSTACK, cursigstk.ss_flags & (SS_DISABLE|SS_ONSTACK));
47}
48
49static void
42call_on_stack(void (*fn)(int)) 50call_on_stack(void (*fn)(int))
43{ 51{
44 /* 52 /*
@@ -106,14 +114,18 @@ static void
106test_without_bzero(int signo) 114test_without_bzero(int signo)
107{ 115{
108 char buf[SECRETBYTES]; 116 char buf[SECRETBYTES];
117 assert_on_stack();
109 populate_secret(buf, sizeof(buf)); 118 populate_secret(buf, sizeof(buf));
119 ASSERT_NE(NULL, memmem(altstack, sizeof(altstack), buf, sizeof(buf)));
110} 120}
111 121
112static void 122static void
113test_with_bzero(int signo) 123test_with_bzero(int signo)
114{ 124{
115 char buf[SECRETBYTES]; 125 char buf[SECRETBYTES];
126 assert_on_stack();
116 populate_secret(buf, sizeof(buf)); 127 populate_secret(buf, sizeof(buf));
128 ASSERT_NE(NULL, memmem(altstack, sizeof(altstack), buf, sizeof(buf)));
117 explicit_bzero(buf, sizeof(buf)); 129 explicit_bzero(buf, sizeof(buf));
118} 130}
119 131