aboutsummaryrefslogtreecommitdiffstats
path: root/debug/printf_chk.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug/printf_chk.c')
-rw-r--r--debug/printf_chk.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/debug/printf_chk.c b/debug/printf_chk.c
index 426dc78386e..e035b425903 100644
--- a/debug/printf_chk.c
+++ b/debug/printf_chk.c
@@ -16,29 +16,23 @@
<http://www.gnu.org/licenses/>. */
#include <stdarg.h>
-#include <stdio.h>
-#include "../libio/libioP.h"
+#include <libio/libioP.h>
/* Write formatted output to stdout from the format string FORMAT. */
int
___printf_chk (int flag, const char *format, ...)
{
+ /* For flag > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n
+ can only come from read-only format strings. */
+ unsigned int mode = (flag > 0) ? PRINTF_FORTIFY : 0;
va_list ap;
- int done;
-
- _IO_acquire_lock_clear_flags2 (stdout);
- if (flag > 0)
- stdout->_flags2 |= _IO_FLAGS2_FORTIFY;
+ int ret;
va_start (ap, format);
- done = vfprintf (stdout, format, ap);
+ ret = __vfprintf_internal (stdout, format, ap, mode);
va_end (ap);
- if (flag > 0)
- stdout->_flags2 &= ~_IO_FLAGS2_FORTIFY;
- _IO_release_lock (stdout);
-
- return done;
+ return ret;
}
ldbl_strong_alias (___printf_chk, __printf_chk)