patch-lib_vasnprintf_c 1.8 KB

12345678910111213141516171819202122232425262728
  1. --- m4-1.4.18.orig/lib/vasnprintf.c 2016-12-31 14:54:42.000000000 +0100
  2. +++ m4-1.4.18/lib/vasnprintf.c 2018-02-24 20:59:00.000000000 +0100
  3. @@ -4858,7 +4858,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *
  4. #endif
  5. *fbp = dp->conversion;
  6. #if USE_SNPRINTF
  7. -# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
  8. +# if ! (((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
  9. + && !defined __UCLIBC__) \
  10. + || (defined __APPLE__ && defined __MACH__) \
  11. + || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
  12. fbp[1] = '%';
  13. fbp[2] = 'n';
  14. fbp[3] = '\0';
  15. @@ -4872,6 +4875,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *
  16. in format strings in writable memory may crash the program
  17. (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
  18. in this situation. */
  19. + /* On Mac OS X 10.3 or newer, we know that snprintf's return
  20. + value conforms to ISO C 99: the tests gl_SNPRINTF_RETVAL_C99
  21. + and gl_SNPRINTF_TRUNCATION_C99 pass.
  22. + Therefore we can avoid using %n in this situation.
  23. + On Mac OS X 10.13 or newer, the use of %n in format strings
  24. + in writable memory by default crashes the program, so we
  25. + should avoid it in this situation. */
  26. /* On native Windows systems (such as mingw), we can avoid using
  27. %n because:
  28. - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,