From: Bruno Haible Date: Wed, 22 Mar 2023 21:37:32 +0000 (+0100) Subject: vasnprintf: Fix potential failure on OpenBSD. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e3d8450d4ab57b938bee499ca39af959d1717704;p=gnulib.git vasnprintf: Fix potential failure on OpenBSD. * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD. --- diff --git a/ChangeLog b/ChangeLog index 09c3398684..6c4494749f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-03-17 Bruno Haible + + vasnprintf: Fix potential failure on OpenBSD. + * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD. + 2023-03-16 Bruno Haible stddef: Fix a compilation error on AIX 7.2 with xlclang. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 72b8cdbfa6..1a30f20d82 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -4992,6 +4992,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 @@ -5007,6 +5008,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 + , + ). - On Android, starting on 2018-03-07, the use of %n in format strings produces a fatal error (see ).