]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add __vsyslog_internal, with same flags as __v*printf_internal.
authorZack Weinberg <zackw@panix.com>
Wed, 7 Mar 2018 19:32:02 +0000 (14:32 -0500)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Wed, 5 Dec 2018 20:15:43 +0000 (18:15 -0200)
__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.

ChangeLog
include/sys/syslog.h
misc/syslog.c
sysdeps/ieee754/ldbl-opt/nldbl-compat.c

index e96f3c60feceec1fbeb172db6432dc011f75fbea..e3bba2ab5ab16565e54e747336912ec3c855d28a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2018-12-05  Zack Weinberg  <zackw@panix.com>
+           Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
+       * misc/syslog.c: Include libioP.h, not iolibio.h.
+       (__vsyslog_internal): New function with the former body of
+       __vsyslog_chk; takes mode_flags argument same as
+       __v*printf_internal.  Call __vfprintf_internal directly.
+
+       (__vsyslog_chk): Now a wrapper around __vsyslog_internal.
+       Remove libc_hidden_def.
+       (__syslog, __syslog_chk): Use __vsyslog_internal.
+       (__vsyslog): Move to just below __syslog.  Use __vsyslog_internal.
+
+       * include/sys/syslog.h: Add multiple inclusion guard.
+       Add prototype for __vsyslog_internal.
+       Remove declaration and libc_hidden_proto for __vsyslog_chk.
+
+       * sysdeps/ieee754/ldbl-opt/nldbl-compat.c (__nldbl___vsyslog_chk):
+       Use __vsyslog_internal.
+
 2018-12-05  Zack Weinberg  <zackw@panix.com>
            Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
 
index 3be3189ed1d405d7942b3a90612ac40223e54d15..89d3479ebc8d58f148d4b7a305e8aff3695ba74b 100644 (file)
@@ -1,11 +1,16 @@
+#ifndef _LIBC_SYS_SYSLOG_H
+#define _LIBC_SYS_SYSLOG_H 1
 #include <misc/sys/syslog.h>
-
 #ifndef _ISOMAC
+
 libc_hidden_proto (syslog)
-libc_hidden_proto (vsyslog)
 
-extern void __vsyslog_chk (int __pri, int __flag, const char *__fmt,
-                          __gnuc_va_list __ap)
-     __attribute__ ((__format__ (__printf__, 3, 0)));
-libc_hidden_proto (__vsyslog_chk)
-#endif
+/* __vsyslog_internal uses the same mode_flags bits as
+   __v*printf_internal; see libio/libioP.h.  */
+extern void __vsyslog_internal (int pri, const char *fmt, __gnuc_va_list ap,
+                               unsigned int mode_flags)
+     attribute_hidden
+     __attribute__ ((__format__ (__printf__, 2, 0)));
+
+#endif /* _ISOMAC */
+#endif /* syslog.h */
index 644dbe80ec0b90d208515c95a53ba2d1ea86dd74..3a15da41ce3a2d7633d65e61d56d4c8c0052a84b 100644 (file)
@@ -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,24 +114,38 @@ __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;
@@ -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 */
 
index bda84af0bbbf45bdb9d9074efc3f252b97927828..958bbc1834aafacc161251475d1f7a425d9b6edf 100644 (file)
@@ -843,7 +843,7 @@ attribute_compat_text_section
 __nldbl___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
 {
   set_no_long_double ();
-  __vsyslog_chk (pri, flag, fmt, ap);
+  __vsyslog_internal (pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
   clear_no_long_double ();
 }
 libc_hidden_def (__nldbl___vsyslog_chk)