]> Savannah Git Hosting - gnulib.git/commitdiff
vasnprintf: Fix potential failure on OpenBSD.
authorBruno Haible <bruno@clisp.org>
Wed, 22 Mar 2023 21:37:32 +0000 (22:37 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 22 Mar 2023 21:51:08 +0000 (22:51 +0100)
* lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD.

ChangeLog
lib/vasnprintf.c

index 017d2ea1a76114bf6c28265f690047b276f0655b..3358b5268dfd6a1f8f15a1b55a188eb2e6eed4fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-03-17  Bruno Haible  <bruno@clisp.org>
+
+       vasnprintf: Fix potential failure on OpenBSD.
+       * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD.
+
 2023-03-16  Bruno Haible  <bruno@clisp.org>
 
        stddef: Fix a compilation error on AIX 7.2 with xlclang.
index 0617aab5bec9539dbd122ca1935196fab61de131..2280e9e71d4f6cba1e07295fa3d56f56d69774d2 100644 (file)
@@ -4993,6 +4993,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__))
                 /* On systems where we know that snprintf's return value
@@ -5008,6 +5009,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                      - On Mac OS X 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>).