]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - debug/vfprintf_chk.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / debug / vfprintf_chk.c
index a9e107d8e5c03df358fbafbe8ea355c8531b6735..e9753ad020be9bfd02bb18721f909fff2a2a9cd0 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997, 2001, 2004
-   Free Software Foundation, Inc.
+/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
-#include <stdarg.h>
-#include <stdio.h>
-#include "../libio/libioP.h"
+#include <libio/libioP.h>
 
 
 /* Write formatted output to FP from the format string FORMAT.  */
 int
-__vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
+___vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
 {
-  int done;
+  /* 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;
 
-  _IO_acquire_lock (fp);
-  if (flag > 0)
-    fp->_flags2 |= _IO_FLAGS2_CHECK_PERCENT_N;
-
-  done = vfprintf (fp, format, ap);
-
-  if (flag > 0)
-    fp->_flags2 &= ~_IO_FLAGS2_CHECK_PERCENT_N;
-  _IO_release_lock (fp);
-
-  return done;
+  return __vfprintf_internal (fp, format, ap, mode);
 }
+ldbl_strong_alias (___vfprintf_chk, __vfprintf_chk)