summaryrefslogtreecommitdiff
path: root/debug/sprintf_chk.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug/sprintf_chk.c')
-rw-r--r--debug/sprintf_chk.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/debug/sprintf_chk.c b/debug/sprintf_chk.c
index 78214563dd..649e8ab4d5 100644
--- a/debug/sprintf_chk.c
+++ b/debug/sprintf_chk.c
@@ -15,22 +15,27 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <libioP.h>
#include <stdarg.h>
-#include <stdio.h>
+#include <libio/libioP.h>
+
/* Write formatted output into S, according to the format string FORMAT. */
-/* VARARGS4 */
int
-___sprintf_chk (char *s, int flags, size_t slen, const char *format, ...)
+___sprintf_chk (char *s, int flag, size_t slen, const char *format, ...)
{
- va_list arg;
- 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;
+ va_list ap;
+ int ret;
+
+ if (slen == 0)
+ __chk_fail ();
- va_start (arg, format);
- done = __vsprintf_chk (s, flags, slen, format, arg);
- va_end (arg);
+ va_start (ap, format);
+ ret = __vsprintf_internal (s, slen, format, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
ldbl_strong_alias (___sprintf_chk, __sprintf_chk)