Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libwrap let's try one more time: prepare the format to p...
details: https://anonhg.NetBSD.org/src/rev/9e120b123dbf
branches: trunk
changeset: 447454:9e120b123dbf
user: christos <christos%NetBSD.org@localhost>
date: Fri Jan 11 16:15:20 2019 +0000
description:
let's try one more time: prepare the format to pass to syslog instead
of trying to escape %m.
diffstat:
lib/libwrap/diag.c | 34 +++++++++++++---------------------
1 files changed, 13 insertions(+), 21 deletions(-)
diffs (63 lines):
diff -r ade574eaa19b -r 9e120b123dbf lib/libwrap/diag.c
--- a/lib/libwrap/diag.c Fri Jan 11 15:43:51 2019 +0000
+++ b/lib/libwrap/diag.c Fri Jan 11 16:15:20 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: diag.c,v 1.14 2019/01/11 13:05:57 christos Exp $ */
+/* $NetBSD: diag.c,v 1.15 2019/01/11 16:15:20 christos Exp $ */
/*
* Routines to report various classes of problems. Each report is decorated
@@ -16,7 +16,7 @@
#if 0
static char sccsid[] = "@(#) diag.c 1.1 94/12/28 17:42:20";
#else
-__RCSID("$NetBSD: diag.c,v 1.14 2019/01/11 13:05:57 christos Exp $");
+__RCSID("$NetBSD: diag.c,v 1.15 2019/01/11 16:15:20 christos Exp $");
#endif
#endif
@@ -45,33 +45,25 @@
static void
tcpd_diag(int severity, const char *tag, const char *fmt, va_list ap)
{
- char *buf, *buf2, *ptr;
- int oerrno = errno;
+ char *buf;
+ int e, oerrno = errno;
- if ((ptr = strstr(fmt, "%m")) != NULL) {
- if (asprintf(&buf, "%.*s%%%s", (int)(ptr - fmt), fmt, ptr) == -1)
- buf = __UNCONST(fmt);
- } else {
+ /* contruct the tag for the log entry */
+ if (tcpd_context.file)
+ e = asprintf(&buf, "%s: %s, line %d: %s",
+ tag, tcpd_context.file, tcpd_context.line, fmt);
+ else
+ e = asprintf(&buf, "%s: %s", tag, fmt);
+
+ if (e == -1)
buf = __UNCONST(fmt);
- }
-
-
- if (vasprintf(&buf2, buf, ap) == -1)
- buf2 = buf;
errno = oerrno;
- /* contruct the tag for the log entry */
- if (tcpd_context.file)
- syslog(severity, "%s: %s, line %d: %s",
- tag, tcpd_context.file, tcpd_context.line, buf2);
- else
- syslog(severity, "%s: %s", tag, buf2);
+ vsyslog(severity, buf, ap);
if (buf != fmt)
free(buf);
- if (buf2 != buf)
- free(buf2);
}
/* tcpd_warn - report problem of some sort and proceed */
Home |
Main Index |
Thread Index |
Old Index