From b5ffaa99ac890d44f61d1a9f3c0f443782523126 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 22 Mar 2023 22:37:32 +0100 Subject: [PATCH] vasnprintf: Fix potential failure on OpenBSD. * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD. --- ChangeLog | 5 +++++ lib/vasnprintf.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 017d2ea1a7..3358b5268d 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 0617aab5be..2280e9e71d 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -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 + , + ). - On Android, starting on 2018-03-07, the use of %n in format strings produces a fatal error (see ). -- 2.39.5