From: Bruno Haible Date: Wed, 21 Feb 2024 11:51:01 +0000 (+0100) Subject: *printf-posix: Avoid crash in another configure test. X-Git-Tag: v1.0~397 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=dd801be6c84325d140c67ec9869b3844bc5550ac;p=gnulib.git *printf-posix: Avoid crash in another configure test. * m4/printf.m4 (gl_SNPRINTF_DIRECTIVE_N): In the test program, catch the SIGABRT signal, so that the program does not dump core. --- diff --git a/ChangeLog b/ChangeLog index dfc1641e74..766d4c798d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-02-21 Bruno Haible + + *printf-posix: Avoid crash in another configure test. + * m4/printf.m4 (gl_SNPRINTF_DIRECTIVE_N): In the test program, catch the + SIGABRT signal, so that the program does not dump core. + 2024-02-20 Bruno Haible unimetadata/u-version: Add tests. diff --git a/m4/printf.m4 b/m4/printf.m4 index 05bf7fe1df..6f917778e8 100644 --- a/m4/printf.m4 +++ b/m4/printf.m4 @@ -1705,6 +1705,7 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], [ AC_RUN_IFELSE( [AC_LANG_SOURCE([[ +#include #include #include #if HAVE_SNPRINTF @@ -1721,11 +1722,18 @@ static int my_snprintf (char *buf, int size, const char *format, ...) return ret; } #endif +static void +abort_handler (int sig) +{ + (void) sig; + _exit (1); +} static char fmtstring[10]; static char buf[100]; int main () { int count = -1; + signal (SIGABRT, abort_handler); /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) support %n in format strings in read-only memory but not in writable memory. */