Ticket #55632: patch-lib-vasnprintf.c.diff

File patch-lib-vasnprintf.c.diff, 2.0 KB (added by ryandesign (Ryan Schmidt), 4 years ago)
  • lib/vasnprintf.c

    Fix runtime crash on macOS High Sierra 10.13 and later.
    https://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00056.html
    http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=c41f233c4c38e84023a16339782ee306f03e7f59
    http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=7df04f9b8a0adb1575ca0555775ec10860143cbf
    old new  
    48714871#endif
    48724872                  *fbp = dp->conversion;
    48734873#if USE_SNPRINTF
    4874 # if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
     4874# if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3))        \
     4875         && !defined __UCLIBC__)                                            \
     4876        || (defined __APPLE__ && defined __MACH__)                          \
     4877        || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
    48754878                fbp[1] = '%';
    48764879                fbp[2] = 'n';
    48774880                fbp[3] = '\0';
     
    48854888                   in format strings in writable memory may crash the program
    48864889                   (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
    48874890                   in this situation.  */
     4891                /* On Mac OS X 10.3 or newer, we know that snprintf's return
     4892                   value conforms to ISO C 99: the tests gl_SNPRINTF_RETVAL_C99
     4893                   and gl_SNPRINTF_TRUNCATION_C99 pass.
     4894                   Therefore we can avoid using %n in this situation.
     4895                   On Mac OS X 10.13 or newer, the use of %n in format strings
     4896                   in writable memory by default crashes the program, so we
     4897                   should avoid it in this situation.  */
    48884898                /* On native Windows systems (such as mingw), we can avoid using
    48894899                   %n because:
    48904900                     - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,