1 From c41f233c4c38e84023a16339782ee306f03e7f59 Mon Sep 17 00:00:00 2001
2 From: Paul Eggert <eggert@cs.ucla.edu>
3 Date: Fri, 7 Jul 2017 14:10:20 -0700
4 Subject: vasnprintf: port to macOS 10.13
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Problem reported by comex in:
10 http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00056.html
11 * lib/vasnprintf.c (VASNPRINTF): Don’t use %n on macOS.
13 lib/vasnprintf.c | 9 ++++++++-
14 2 files changed, 15 insertions(+), 1 deletion(-)
16 diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
17 index 9c2af0e..fecaf27 100644
18 --- a/lib/vasnprintf.c
19 +++ b/lib/vasnprintf.c
20 @@ -4869,7 +4869,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
22 *fbp = dp->conversion;
24 -# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
25 +# if ! (((__GLIBC__ > 2 \
26 + || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
27 + && !defined __UCLIBC__) \
28 + || (defined __APPLE__ && defined __MACH__) \
29 + || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
33 @@ -4883,6 +4887,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
34 in format strings in writable memory may crash the program
35 (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
37 + /* macOS 10.13 High Sierra behaves like glibc with
38 + _FORTIFY_SOURCE=2, and older macOS releases
39 + presumably do not need %n. */
40 /* On native Windows systems (such as mingw), we can avoid using
42 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,