summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2024-11-25 17:32:54 +0100
committerH.J. Lu <hjl.tools@gmail.com>2025-08-19 09:07:52 -0700
commit3b6c8ea8782b7bbc50b93d8bf3a61d52cef7a5cb (patch)
tree100839e099775cc98108c1e0ee0f6408f9676b65
parent89596f46e3113bd9643e7d5a90e6f7db11259086 (diff)
debug: Wire up tst-longjmp_chk3
The test was added in commit ac8cc9e300a002228eb7e660df3e7b333d9a7414 without all the required Makefile scaffolding. Tweak the test so that it actually builds (including with dynamic SIGSTKSZ). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 4b7cfcc3fbfab55a1bbb32a2da69c048060739d6)
-rw-r--r--debug/Makefile1
-rw-r--r--debug/tst-longjmp_chk3.c13
2 files changed, 10 insertions, 4 deletions
diff --git a/debug/Makefile b/debug/Makefile
index 3903cc97a3..76c311d284 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -287,6 +287,7 @@ tests = \
tst-fortify-wide \
tst-longjmp_chk \
tst-longjmp_chk2 \
+ tst-longjmp_chk3 \
tst-realpath-chk \
tst-sprintf-fortify-rdonly \
tst-sprintf-fortify-unchecked \
diff --git a/debug/tst-longjmp_chk3.c b/debug/tst-longjmp_chk3.c
index 9ff9977207..7bf1646b35 100644
--- a/debug/tst-longjmp_chk3.c
+++ b/debug/tst-longjmp_chk3.c
@@ -18,9 +18,12 @@
#include <setjmp.h>
#include <signal.h>
+#include <stdio.h>
#include <string.h>
-static char buf[SIGSTKSZ * 4];
+#include <support/support.h>
+
+static char *buf;
static jmp_buf jb;
static void
@@ -49,8 +52,10 @@ do_test (void)
set_fortify_handler (handler);
/* Create a valid signal stack and enable it. */
+ size_t bufsize = SIGSTKSZ * 4;
+ buf = xmalloc (bufsize);
ss.ss_sp = buf;
- ss.ss_size = sizeof (buf);
+ ss.ss_size = bufsize;
ss.ss_flags = 0;
if (sigaltstack (&ss, NULL) < 0)
{
@@ -65,8 +70,8 @@ do_test (void)
/* Shrink the signal stack so the jmpbuf is now invalid.
We adjust the start & end to handle stacks that grow up & down. */
- ss.ss_sp = buf + sizeof (buf) / 2;
- ss.ss_size = sizeof (buf) / 4;
+ ss.ss_sp = buf + bufsize / 2;
+ ss.ss_size = bufsize / 4;
if (sigaltstack (&ss, NULL) < 0)
{
printf ("second sigaltstack failed: %m\n");