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
|
|
4871 | 4871 | #endif |
4872 | 4872 | *fbp = dp->conversion; |
4873 | 4873 | #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__)) |
4875 | 4878 | fbp[1] = '%'; |
4876 | 4879 | fbp[2] = 'n'; |
4877 | 4880 | fbp[3] = '\0'; |
… |
… |
|
4885 | 4888 | in format strings in writable memory may crash the program |
4886 | 4889 | (if compiled with _FORTIFY_SOURCE=2), so we should avoid it |
4887 | 4890 | 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. */ |
4888 | 4898 | /* On native Windows systems (such as mingw), we can avoid using |
4889 | 4899 | %n because: |
4890 | 4900 | - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, |