about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2018-03-07 14:32:02 -0500
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-12-05 18:15:43 -0200
commit124fc732c15ef37b7ee9db25b1e9f9b20c799623 (patch)
tree75f6e01ee571f6f1ae901b09669d89381945e881 /misc
parent698fb75b9ff5ae454a1344b5f9fafa0ca367c555 (diff)
downloadglibc-124fc732c15ef37b7ee9db25b1e9f9b20c799623.tar.gz
glibc-124fc732c15ef37b7ee9db25b1e9f9b20c799623.tar.xz
glibc-124fc732c15ef37b7ee9db25b1e9f9b20c799623.zip
Add __vsyslog_internal, with same flags as __v*printf_internal.
__nldbl___vsyslog_chk will ultimately want to pass PRINTF_LDBL_IS_DBL
down to __vfprintf_internal *as well as* possibly setting PRINTF_FORTIFY.
To make that possible, we need a __vsyslog_internal that takes the
same flags as printf.  The code in misc/syslog.c does also get a
little simpler.

Tested for powerpc and powerpc64le.
Diffstat (limited to 'misc')
-rw-r--r--misc/syslog.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/misc/syslog.c b/misc/syslog.c
index 644dbe80ec..3a15da41ce 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -53,7 +53,7 @@ static char sccsid[] = "@(#)syslog.c	8.4 (Berkeley) 3/18/94";
 
 #include <stdarg.h>
 
-#include <libio/iolibio.h>
+#include <libio/libioP.h>
 #include <math_ldbl_opt.h>
 
 #include <kernel-features.h>
@@ -114,25 +114,39 @@ __syslog(int pri, const char *fmt, ...)
 	va_list ap;
 
 	va_start(ap, fmt);
-	__vsyslog_chk(pri, -1, fmt, ap);
+	__vsyslog_internal(pri, fmt, ap, 0);
 	va_end(ap);
 }
 ldbl_hidden_def (__syslog, syslog)
 ldbl_strong_alias (__syslog, syslog)
 
 void
+__vsyslog(int pri, const char *fmt, va_list ap)
+{
+	__vsyslog_internal(pri, fmt, ap, 0);
+}
+ldbl_weak_alias (__vsyslog, vsyslog)
+
+void
 __syslog_chk(int pri, int flag, const char *fmt, ...)
 {
 	va_list ap;
 
 	va_start(ap, fmt);
-	__vsyslog_chk(pri, flag, fmt, ap);
+	__vsyslog_internal(pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
 	va_end(ap);
 }
 
 void
 __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
 {
+	__vsyslog_internal(pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
+}
+
+void
+__vsyslog_internal(int pri, const char *fmt, va_list ap,
+		   unsigned int mode_flags)
+{
 	struct tm now_tm;
 	time_t now;
 	int fd;
@@ -215,11 +229,8 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
 	    __set_errno (saved_errno);
 
 	    /* We have the header.  Print the user's format into the
-               buffer.  */
-	    if (flag == -1)
-	      vfprintf (f, fmt, ap);
-	    else
-	      __vfprintf_chk (f, flag, fmt, ap);
+	       buffer.  */
+	    __vfprintf_internal (f, fmt, ap, mode_flags);
 
 	    /* Close the memory stream; this will finalize the data
 	       into a malloc'd buffer in BUF.  */
@@ -316,15 +327,6 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
 	if (buf != failbuf)
 		free (buf);
 }
-libc_hidden_def (__vsyslog_chk)
-
-void
-__vsyslog(int pri, const char *fmt, va_list ap)
-{
-  __vsyslog_chk (pri, -1, fmt, ap);
-}
-ldbl_hidden_def (__vsyslog, vsyslog)
-ldbl_weak_alias (__vsyslog, vsyslog)
 
 static struct sockaddr_un SyslogAddr;	/* AF_UNIX address of local logger */