summaryrefslogtreecommitdiff
path: root/lib/vasnprintf.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-07-07 14:10:20 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2017-07-07 14:12:39 -0700
commitc41f233c4c38e84023a16339782ee306f03e7f59 (patch)
treee0f4bc39b6fe032a4e92d54c1b4d9f040f6518d7 /lib/vasnprintf.c
parenta00180247558d3aeb1e3ae06d1b6bb6d4bd1adc6 (diff)
downloadgnulib-c41f233c4c38e84023a16339782ee306f03e7f59.tar.gz
vasnprintf: port to macOS 10.13
Problem reported by comex in: http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00056.html * lib/vasnprintf.c (VASNPRINTF): Don’t use %n on macOS.
Diffstat (limited to 'lib/vasnprintf.c')
-rw-r--r--lib/vasnprintf.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 9c2af0e45e..fecaf27a1d 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -4869,7 +4869,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#endif
*fbp = dp->conversion;
#if USE_SNPRINTF
-# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# if ! (((__GLIBC__ > 2 \
+ || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
+ && !defined __UCLIBC__) \
+ || (defined __APPLE__ && defined __MACH__) \
+ || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
fbp[1] = '%';
fbp[2] = 'n';
fbp[3] = '\0';
@@ -4883,6 +4887,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
in format strings in writable memory may crash the program
(if compiled with _FORTIFY_SOURCE=2), so we should avoid it
in this situation. */
+ /* macOS 10.13 High Sierra behaves like glibc with
+ _FORTIFY_SOURCE=2, and older macOS releases
+ presumably do not need %n. */
/* On native Windows systems (such as mingw), we can avoid using
%n because:
- Although the gl_SNPRINTF_TRUNCATION_C99 test fails,