From: deraadt Date: Wed, 21 Jan 2015 19:34:24 +0000 (+0000) Subject: Truncate progname to NAME_MAX in the syslog message, to ensure other X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=77f213570c1a3a662126cbd93c8093f75f5d36e1;p=openbsd 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 --- 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 #include #include +#include #include 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) {