]> Savannah Git Hosting - gnulib.git/commitdiff
vasnprintf: port to macOS 10.13
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 7 Jul 2017 21:10:20 +0000 (14:10 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 7 Jul 2017 21:12:39 +0000 (14:12 -0700)
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.

ChangeLog
lib/vasnprintf.c

index 14fa6fa15222d6e591db4e29e9237d9ccc4f116f..176abb98c7c6b25f515c84f756ffdd2054c56a6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-07-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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.
+
 2017-07-06  Bruno Haible  <bruno@clisp.org>
 
        imaxdiv tests: Fix logic.
index 9c2af0e45e00d437b1d1ccb8f6d8952353d06fbc..fecaf27a1d8cf7c0758930a9b7232e9b8c675d01 100644 (file)
@@ -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,