From: Bruno Haible Date: Sun, 8 Mar 2020 21:54:02 +0000 (+0100) Subject: *printf-posix: Document why it's overridden on some glibc systems. X-Git-Tag: v1.0~4191 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1045f81589d74392c0d634c21f0452e81c973a9b;p=gnulib.git *printf-posix: Document why it's overridden on some glibc systems. Reported by Adrian Bunk in . * doc/posix-functions/*printf.texi: Document the problem with the %n directive on some glibc systems. * m4/printf.m4 (gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N): Adjust the cross-compilation guesses accordingly. --- diff --git a/ChangeLog b/ChangeLog index d36c58b98a..46fce2b50c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2020-03-08 Bruno Haible + + *printf-posix: Document why it's overridden on some glibc systems. + Reported by Adrian Bunk in + . + * doc/posix-functions/*printf.texi: Document the problem with the %n + directive on some glibc systems. + * m4/printf.m4 (gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N): Adjust + the cross-compilation guesses accordingly. + 2020-03-07 Paul Eggert open, openat: port to (O_RDWR | O_RDONLY) != 0 diff --git a/doc/posix-functions/fprintf.texi b/doc/posix-functions/fprintf.texi index a596bcbbfd..f55580634f 100644 --- a/doc/posix-functions/fprintf.texi +++ b/doc/posix-functions/fprintf.texi @@ -30,6 +30,7 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.x, mingw, MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item This function does not support the @samp{ls} directive on some platforms: diff --git a/doc/posix-functions/printf.texi b/doc/posix-functions/printf.texi index 3f00531d33..1216656f24 100644 --- a/doc/posix-functions/printf.texi +++ b/doc/posix-functions/printf.texi @@ -30,6 +30,7 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.x, mingw, MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item This function does not support the @samp{ls} directive on some platforms: diff --git a/doc/posix-functions/snprintf.texi b/doc/posix-functions/snprintf.texi index 477931fab3..6724043a55 100644 --- a/doc/posix-functions/snprintf.texi +++ b/doc/posix-functions/snprintf.texi @@ -45,6 +45,7 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.x, mingw, MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item This function does not support the @samp{ls} directive on some platforms: diff --git a/doc/posix-functions/sprintf.texi b/doc/posix-functions/sprintf.texi index c43dd15262..a8808990ee 100644 --- a/doc/posix-functions/sprintf.texi +++ b/doc/posix-functions/sprintf.texi @@ -30,6 +30,7 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.x, mingw, MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item This function does not support the @samp{ls} directive on some platforms: diff --git a/doc/posix-functions/swprintf.texi b/doc/posix-functions/swprintf.texi index b5aca13ad3..4d849ae5bd 100644 --- a/doc/posix-functions/swprintf.texi +++ b/doc/posix-functions/swprintf.texi @@ -27,6 +27,7 @@ This function is only defined as a macro on some platforms: MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item On Windows and 32-bit AIX platforms, @code{wchar_t} is a 16-bit type and therefore cannot diff --git a/doc/posix-functions/vfprintf.texi b/doc/posix-functions/vfprintf.texi index 0e7ecba84b..a87219eaa3 100644 --- a/doc/posix-functions/vfprintf.texi +++ b/doc/posix-functions/vfprintf.texi @@ -30,6 +30,7 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.x, mingw, MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item This function does not support the @samp{ls} directive on some platforms: diff --git a/doc/posix-functions/vprintf.texi b/doc/posix-functions/vprintf.texi index 09d9e2b6e2..0cb573c25d 100644 --- a/doc/posix-functions/vprintf.texi +++ b/doc/posix-functions/vprintf.texi @@ -30,6 +30,7 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.x, mingw, MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item This function does not support the @samp{ls} directive on some platforms: diff --git a/doc/posix-functions/vsnprintf.texi b/doc/posix-functions/vsnprintf.texi index de5258dd24..8f2f41065f 100644 --- a/doc/posix-functions/vsnprintf.texi +++ b/doc/posix-functions/vsnprintf.texi @@ -75,6 +75,7 @@ This function does not truncate the result as specified in C99 on some platforms mingw, MSVC 14. @item This function does not fully support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), HP-UX 11, mingw, MSVC 14. @item This function overwrites memory even when a zero size argument is passed on some diff --git a/doc/posix-functions/vsprintf.texi b/doc/posix-functions/vsprintf.texi index 71da5ccfd4..4e264c7d27 100644 --- a/doc/posix-functions/vsprintf.texi +++ b/doc/posix-functions/vsprintf.texi @@ -30,6 +30,7 @@ NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.x, mingw, MSVC 14. @item This function does not support the @samp{n} directive on some platforms: +glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu), MSVC 14. @item This function does not support the @samp{ls} directive on some platforms: diff --git a/m4/printf.m4 b/m4/printf.m4 index 9df21534b1..54a2d71314 100644 --- a/m4/printf.m4 +++ b/m4/printf.m4 @@ -1,4 +1,4 @@ -# printf.m4 serial 62 +# printf.m4 serial 63 dnl Copyright (C) 2003, 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -711,6 +711,16 @@ int main () [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], [case "$host_os" in + # Guess no on glibc when _FORTIFY_SOURCE >= 2. + *-gnu* | gnu*) AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if _FORTIFY_SOURCE >= 2 + error fail + #endif + ]])], + [gl_cv_func_printf_directive_n="guessing yes"], + [gl_cv_func_printf_directive_n="guessing no"]) + ;; # Guess no on Android. linux*-android*) gl_cv_func_printf_directive_n="guessing no";; # Guess no on native Windows. @@ -1414,8 +1424,16 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess yes on glibc systems. - *-gnu* | gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess no on glibc when _FORTIFY_SOURCE >= 2. + *-gnu* | gnu*) AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[#if _FORTIFY_SOURCE >= 2 + error fail + #endif + ]])], + [gl_cv_func_snprintf_directive_n="guessing yes"], + [gl_cv_func_snprintf_directive_n="guessing no"]) + ;; # Guess yes on musl systems. *-musl*) gl_cv_func_snprintf_directive_n="guessing yes";; # Guess yes on FreeBSD >= 5.