From 77f213570c1a3a662126cbd93c8093f75f5d36e1 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 21 Jan 2015 19:34:24 +0000 Subject: [PATCH] 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 --- lib/libc/gen/syslog_r.c | 5 +++-- 1 file 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 #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) { -- 2.20.1