1 diff --git a/tests/explicit_bzero.c b/tests/explicit_bzero.c
2 index 34c60baa8a..9c0e917829 100644
3 --- a/tests/explicit_bzero.c
4 +++ b/tests/explicit_bzero.c
6 -/* $OpenBSD: explicit_bzero.c,v 1.6 2014/07/11 01:10:35 matthew Exp $ */
7 +/* $OpenBSD: explicit_bzero.c,v 1.7 2021/03/27 11:17:58 bcook Exp $ */
9 * Copyright (c) 2014 Google Inc.
19 @@ -36,19 +37,33 @@ enum {
20 SECRETBYTES = SECRETCOUNT * sizeof(secret)
23 -static char altstack[SIGSTKSZ + SECRETBYTES];
25 + * As of glibc 2.34, when _GNU_SOURCE is defined, SIGSTKSZ is no longer
26 + * constant on Linux. SIGSTKSZ is redefined to sysconf (_SC_SIGSTKSZ).
28 +static char *altstack;
29 +#define ALTSTACK_SIZE (SIGSTKSZ + SECRETBYTES)
34 + altstack = calloc(1, ALTSTACK_SIZE);
35 + ASSERT_NE(NULL, altstack);
37 const stack_t sigstk = {
39 - .ss_size = sizeof(altstack),
40 + .ss_size = ALTSTACK_SIZE
43 ASSERT_EQ(0, sigaltstack(&sigstk, NULL));
55 @@ -129,7 +144,7 @@ test_without_bzero()
56 char buf[SECRETBYTES];
58 populate_secret(buf, sizeof(buf));
59 - char *res = memmem(altstack, sizeof(altstack), buf, sizeof(buf));
60 + char *res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
64 @@ -140,7 +155,7 @@ test_with_bzero()
65 char buf[SECRETBYTES];
67 populate_secret(buf, sizeof(buf));
68 - char *res = memmem(altstack, sizeof(altstack), buf, sizeof(buf));
69 + char *res = memmem(altstack, ALTSTACK_SIZE, buf, sizeof(buf));
71 explicit_bzero(buf, sizeof(buf));
73 @@ -183,15 +198,17 @@ main()
74 * on the stack. This sanity checks that call_on_stack() and
75 * populate_secret() work as intended.
77 - memset(altstack, 0, sizeof(altstack));
78 + memset(altstack, 0, ALTSTACK_SIZE);
79 call_on_stack(do_test_without_bzero);
82 * Now test with a call to explicit_bzero() and check that we
83 * *don't* find any instances of the secret data.
85 - memset(altstack, 0, sizeof(altstack));
86 + memset(altstack, 0, ALTSTACK_SIZE);
87 call_on_stack(do_test_with_bzero);