diff options
author | 2015-01-21 19:34:24 +0000 | |
---|---|---|
committer | 2015-01-21 19:34:24 +0000 | |
commit | 77f213570c1a3a662126cbd93c8093f75f5d36e1 (patch) | |
tree | 4d2324e3ababf0eebefca30c6f88b76dcbeae4f9 /lib/libc/gen/syslog_r.c | |
parent | Use plain "-p" to specify "halt and power down", for consistency (diff) | |
download | wireguard-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.c | 5 |
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) { |