aboutsummaryrefslogtreecommitdiff
path: root/debug/fwprintf_chk.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug/fwprintf_chk.c')
-rw-r--r--debug/fwprintf_chk.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/debug/fwprintf_chk.c b/debug/fwprintf_chk.c
index 63167c1839..10d84ce98b 100644
--- a/debug/fwprintf_chk.c
+++ b/debug/fwprintf_chk.c
@@ -16,28 +16,22 @@
<http://www.gnu.org/licenses/>. */
#include <stdarg.h>
-#include <wchar.h>
-#include "../libio/libioP.h"
+#include <libio/libioP.h>
/* Write formatted output to FP from the format string FORMAT. */
int
__fwprintf_chk (FILE *fp, int flag, const wchar_t *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 (fp);
- if (flag > 0)
- fp->_flags2 |= _IO_FLAGS2_FORTIFY;
+ int ret;
va_start (ap, format);
- done = __vfwprintf_internal (fp, format, ap, 0);
+ ret = __vfwprintf_internal (fp, format, ap, mode);
va_end (ap);
- if (flag > 0)
- fp->_flags2 &= ~_IO_FLAGS2_FORTIFY;
- _IO_release_lock (fp);
-
- return done;
+ return ret;
}