]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
debug: Wire up tst-longjmp_chk3
authorFlorian Weimer <fweimer@redhat.com>
Mon, 25 Nov 2024 16:32:54 +0000 (17:32 +0100)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 19 Aug 2025 15:54:28 +0000 (08:54 -0700)
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)

debug/Makefile
debug/tst-longjmp_chk3.c

index 434e52f7804e11428fe8bdaa8a07515e02547ba1..439f860eb1c4c0fb78e2cc3f6747647de303ae29 100644 (file)
@@ -283,6 +283,7 @@ tests = \
   tst-backtrace6 \
   tst-longjmp_chk \
   tst-longjmp_chk2 \
+  tst-longjmp_chk3 \
   tst-realpath-chk \
   tst-sprintf-fortify-unchecked \
   # tests
index 3050806c443da1311b20bf92fce9c99aedac5b7f..f1562c4b099cdb256d97cfa6c6f38b5e850ef8a9 100644 (file)
 
 #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");