1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

tests: unify fortification handler logic

We have multiple tests that copy & paste the same logic for disabling the
fortification output.  Let's unify this in the test-skeleton instead.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
Mike Frysinger
2013-12-29 23:13:20 +00:00
parent 10444e425e
commit c5bb8e2399
6 changed files with 58 additions and 79 deletions

View File

@ -54,6 +54,10 @@ simple_strcpy_chk (char *dst, const char *src, size_t len)
#include <setjmp.h>
#include <signal.h>
static int test_main (void);
#define TEST_FUNCTION test_main ()
#include "../test-skeleton.c"
volatile int chk_fail_ok;
jmp_buf chk_fail_buf;
@ -266,28 +270,12 @@ Iteration %zd - different strings, %s (%zd, %zd, %zd)\n",
}
}
int
static int
test_main (void)
{
size_t i;
struct sigaction sa;
sa.sa_handler = handler;
sa.sa_flags = 0;
sigemptyset (&sa.sa_mask);
sigaction (SIGABRT, &sa, NULL);
/* Avoid all the buffer overflow messages on stderr. */
int fd = open (_PATH_DEVNULL, O_WRONLY);
if (fd == -1)
close (STDERR_FILENO);
else
{
dup2 (fd, STDERR_FILENO);
close (fd);
}
setenv ("LIBC_FATAL_STDERR_", "1", 1);
set_fortify_handler (handler);
test_init ();
@ -365,5 +353,3 @@ test_main (void)
do_random_tests ();
return ret;
}
#include "../test-skeleton.c"