1
0
Fork 0
mirror of git://sourceware.org/git/glibc.git synced 2025-03-06 20:58:33 +01:00

debug: Wire up tst-longjmp_chk3

The test was added in commit ac8cc9e300
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>
This commit is contained in:
Florian Weimer 2024-11-25 17:32:54 +01:00
parent d9f40387d3
commit 4b7cfcc3fb
2 changed files with 10 additions and 4 deletions

View file

@ -288,6 +288,7 @@ tests = \
tst-fortify-wide \ tst-fortify-wide \
tst-longjmp_chk \ tst-longjmp_chk \
tst-longjmp_chk2 \ tst-longjmp_chk2 \
tst-longjmp_chk3 \
tst-realpath-chk \ tst-realpath-chk \
tst-sprintf-fortify-rdonly \ tst-sprintf-fortify-rdonly \
tst-sprintf-fortify-unchecked \ tst-sprintf-fortify-unchecked \

View file

@ -18,9 +18,12 @@
#include <setjmp.h> #include <setjmp.h>
#include <signal.h> #include <signal.h>
#include <stdio.h>
#include <string.h> #include <string.h>
static char buf[SIGSTKSZ * 4]; #include <support/support.h>
static char *buf;
static jmp_buf jb; static jmp_buf jb;
static void static void
@ -49,8 +52,10 @@ do_test (void)
set_fortify_handler (handler); set_fortify_handler (handler);
/* Create a valid signal stack and enable it. */ /* Create a valid signal stack and enable it. */
size_t bufsize = SIGSTKSZ * 4;
buf = xmalloc (bufsize);
ss.ss_sp = buf; ss.ss_sp = buf;
ss.ss_size = sizeof (buf); ss.ss_size = bufsize;
ss.ss_flags = 0; ss.ss_flags = 0;
if (sigaltstack (&ss, NULL) < 0) if (sigaltstack (&ss, NULL) < 0)
{ {
@ -65,8 +70,8 @@ do_test (void)
/* Shrink the signal stack so the jmpbuf is now invalid. /* Shrink the signal stack so the jmpbuf is now invalid.
We adjust the start & end to handle stacks that grow up & down. */ We adjust the start & end to handle stacks that grow up & down. */
ss.ss_sp = buf + sizeof (buf) / 2; ss.ss_sp = buf + bufsize / 2;
ss.ss_size = sizeof (buf) / 4; ss.ss_size = bufsize / 4;
if (sigaltstack (&ss, NULL) < 0) if (sigaltstack (&ss, NULL) < 0)
{ {
printf ("second sigaltstack failed: %m\n"); printf ("second sigaltstack failed: %m\n");