]> Savannah Git Hosting - gnulib.git/commitdiff
vasnwprintf: Fix test failure on OpenBSD.
authorBruno Haible <bruno@clisp.org>
Fri, 17 Mar 2023 18:16:26 +0000 (19:16 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 17 Mar 2023 18:16:26 +0000 (19:16 +0100)
* lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD.

ChangeLog
lib/vasnprintf.c

index 27eea4df8c7f9c4a5d698677ff992905a4b4f78e..8318d7f6fcb660aecbb11d337106e76051ae0cc1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-03-17  Bruno Haible  <bruno@clisp.org>
+
+       vasnwprintf: Fix test failure on OpenBSD.
+       * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD.
+
 2023-03-17  Bruno Haible  <bruno@clisp.org>
 
        time: Fix test failure on AIX 7.2.
index f0575979eaa9e128b5d722f0376dfdba2d23d521..74a6712926af2392744487024f90a425cd8e84ed 100644 (file)
@@ -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.