summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/syslog_r.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-01-21 19:34:24 +0000
committerderaadt <deraadt@openbsd.org>2015-01-21 19:34:24 +0000
commit77f213570c1a3a662126cbd93c8093f75f5d36e1 (patch)
tree4d2324e3ababf0eebefca30c6f88b76dcbeae4f9 /lib/libc/gen/syslog_r.c
parentUse plain "-p" to specify "halt and power down", for consistency (diff)
downloadwireguard-openbsd-77f213570c1a3a662126cbd93c8093f75f5d36e1.tar.xz
wireguard-openbsd-77f213570c1a3a662126cbd93c8093f75f5d36e1.zip
Truncate progname to NAME_MAX in the syslog message, to ensure other
information also makes it through. This is a compromise to cope with the absolutely ridiculous setprogname() API. ok various discussions
Diffstat (limited to 'lib/libc/gen/syslog_r.c')
-rw-r--r--lib/libc/gen/syslog_r.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/gen/syslog_r.c b/lib/libc/gen/syslog_r.c
index 1f993f446bd..4f758fdd000 100644
--- a/lib/libc/gen/syslog_r.c
+++ b/lib/libc/gen/syslog_r.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslog_r.c,v 1.6 2014/10/03 15:41:18 bluhm Exp $ */
+/* $OpenBSD: syslog_r.c,v 1.7 2015/01/21 19:34:24 deraadt Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -40,6 +40,7 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <limits.h>
#include <stdarg.h>
extern char *__progname; /* Program name, from crt0. */
@@ -144,7 +145,7 @@ __vsyslog_r(int pri, struct syslog_data *data,
if (data->log_tag == NULL)
data->log_tag = __progname;
if (data->log_tag != NULL) {
- prlen = snprintf(p, tbuf_left, "%s", data->log_tag);
+ prlen = snprintf(p, tbuf_left, "%.*s", NAME_MAX, data->log_tag);
DEC();
}
if (data->log_stat & LOG_PID) {