From: Bruno Haible Date: Fri, 17 Mar 2023 18:16:26 +0000 (+0100) Subject: vasnwprintf: Fix test failure on OpenBSD. X-Git-Tag: v1.0~1631 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=fa7279f31f55813cc82766213ee415ef11c83f90;p=gnulib.git vasnwprintf: Fix test failure on OpenBSD. * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD. --- diff --git a/ChangeLog b/ChangeLog index 27eea4df8c..8318d7f6fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-03-17 Bruno Haible + + vasnwprintf: Fix test failure on OpenBSD. + * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD. + 2023-03-17 Bruno Haible time: Fix test failure on AIX 7.2. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index f0575979ea..74a6712926 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -4995,6 +4995,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \ && !defined __UCLIBC__) \ || (defined __APPLE__ && defined __MACH__) \ + || defined __OpenBSD__ \ || defined __ANDROID__ \ || (defined _WIN32 && ! defined __CYGWIN__)) /* We can avoid passing %n and instead rely on SNPRINTF's @@ -5024,6 +5025,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, - On macOS 10.13 or newer, the use of %n in format strings in writable memory by default crashes the program. + - On OpenBSD, since 2021-08-30, the use of %n in format + strings produces an abort (see + , + ). - On Android, starting on 2018-03-07, the use of %n in format strings produces a fatal error (see ). @@ -5032,7 +5037,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, crashes the program. See and - On the first three of these platforms, if !WIDE_CHAR_VERSION, + On the first four of these platforms, if !WIDE_CHAR_VERSION, it is not a big deal to avoid %n, because on these platforms, HAVE_SNPRINTF_RETVAL_C99 and HAVE_SNPRINTF_TRUNCATION_C99 are 1.