From: Zack Weinberg <zackw@panix.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 6/9] Add __vsyslog_internal, with same flags as __v*printf_internal.
Date: Wed, 07 Mar 2018 19:32:00 -0000 [thread overview]
Message-ID: <20180307193205.4751-7-zackw@panix.com> (raw)
In-Reply-To: <20180307193205.4751-1-zackw@panix.com>
__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.
* 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 libc_hidden_proto for __vsyslog_chk.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.c (__nldbl___vsyslog_chk):
Use __vsyslog_internal.
---
include/sys/syslog.h | 15 +++++++++++---
misc/syslog.c | 35 ++++++++++++++++++---------------
sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 2 +-
3 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/include/sys/syslog.h b/include/sys/syslog.h
index 3be3189ed1..459ca70746 100644
--- a/include/sys/syslog.h
+++ b/include/sys/syslog.h
@@ -1,11 +1,20 @@
+#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)
+/* __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__ ((__format__ (__printf__, 2, 0)));
+
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
+
+#endif /* _ISOMAC */
+#endif /* syslog.h */
diff --git a/misc/syslog.c b/misc/syslog.c
index 644dbe80ec..eb1283a604 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,24 +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_hidden_def (__vsyslog, vsyslog)
+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;
@@ -216,10 +231,7 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
/* 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);
+ __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 +328,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 */
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
index 7e8af80d63..f00eb55eb5 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -842,7 +842,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)
--
2.16.2
next prev parent reply other threads:[~2018-03-07 19:32 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 19:32 [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-07 19:32 ` [PATCH 3/9] Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD Zack Weinberg
2018-03-26 15:35 ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 8/9] Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-07 19:32 ` [PATCH 4/9] Use SCANF_LDBL_IS_DBL " Zack Weinberg
2018-03-14 12:22 ` Florian Weimer
2018-03-26 15:36 ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 2/9] Add __vfscanf_internal and __vfwscanf_internal with flags arguments Zack Weinberg
2018-03-13 12:35 ` Adhemerval Zanella
2018-06-29 14:04 ` Florian Weimer
2018-03-26 15:28 ` Gabriel F. T. Gomes
2018-06-29 14:12 ` Florian Weimer
2018-06-29 14:24 ` Florian Weimer
2018-06-29 14:29 ` Florian Weimer
2018-03-07 19:32 ` [PATCH 1/9] Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-12 20:36 ` Adhemerval Zanella
2018-03-12 21:11 ` Zack Weinberg
2018-03-13 11:45 ` Adhemerval Zanella
2018-03-26 15:17 ` Gabriel F. T. Gomes
2018-03-26 15:40 ` Zack Weinberg
2018-03-26 15:52 ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 5/9] Add __v*printf_internal with flags arguments Zack Weinberg
2018-03-26 15:41 ` Gabriel F. T. Gomes
2018-03-07 19:32 ` Zack Weinberg [this message]
2018-03-13 11:59 ` [PATCH 6/9] Add __vsyslog_internal, with same flags as __v*printf_internal Florian Weimer
2018-03-13 12:39 ` Zack Weinberg
2018-03-13 12:43 ` Florian Weimer
2018-03-13 13:37 ` Zack Weinberg
2018-03-13 13:50 ` Florian Weimer
2018-03-13 14:11 ` Zack Weinberg
2018-03-13 14:13 ` Florian Weimer
2018-03-07 19:51 ` [PATCH 9/9] Post-cleanup: don't include math.h/math_private.h in math_ldbl_opt.h Zack Weinberg
2018-03-07 19:51 ` [PATCH 7/9] Use PRINTF_FORTIFY instead of _IO_FLAGS2_FORTIFY Zack Weinberg
2018-03-12 15:29 ` [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-26 15:16 ` Gabriel F. T. Gomes
2018-03-26 15:47 ` Zack Weinberg
2018-06-27 15:50 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180307193205.4751-7-zackw@panix.com \
--to=zackw@panix.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).