summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-03-17 19:16:26 +0100
committerBruno Haible <bruno@clisp.org>2023-03-17 19:16:26 +0100
commitfa7279f31f55813cc82766213ee415ef11c83f90 (patch)
tree4d9e92f21594b122d763dae55623efb5e5b34483 /lib
parent1314bf911af271ca5c5cf51245f880c41d0684b7 (diff)
downloadgnulib-fa7279f31f55813cc82766213ee415ef11c83f90.tar.gz
vasnwprintf: Fix test failure on OpenBSD.
* lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD.
Diffstat (limited to 'lib')
-rw-r--r--lib/vasnprintf.c7
1 files changed, 6 insertions, 1 deletions
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
+ <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/vfprintf.c.diff?r1=1.79&r2=1.80&f=h>,
+ <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/vfwprintf.c.diff?r1=1.20&r2=1.21&f=h>).
- On Android, starting on 2018-03-07, the use of %n in
format strings produces a fatal error (see
<https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>).
@@ -5032,7 +5037,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
crashes the program. See
<https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
<https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
- 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.