summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2003-05-17 17:49:28 +0000
committermillert <millert@openbsd.org>2003-05-17 17:49:28 +0000
commitca094daa8162e1d5b16e38ccf0381af483feeac9 (patch)
tree957f93d74f2ab39473078319cf054f86649fe950
parentCorrect chipset identification from netbsd (diff)
downloadwireguard-openbsd-ca094daa8162e1d5b16e38ccf0381af483feeac9.tar.xz
wireguard-openbsd-ca094daa8162e1d5b16e38ccf0381af483feeac9.zip
Cannot use strlcpy() for strings in struct utmp since they are not guaranteed
to be NUL-terminated. Fixes a bug introduced in rev 1.37; noticed by deraadt@
-rw-r--r--usr.sbin/syslogd/syslogd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 30a0457c7c1..afd9d56542e 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.60 2003/03/21 19:28:58 millert Exp $ */
+/* $OpenBSD: syslogd.c,v 1.61 2003/05/17 17:49:28 millert Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
#else
-static char rcsid[] = "$OpenBSD: syslogd.c,v 1.60 2003/03/21 19:28:58 millert Exp $";
+static char rcsid[] = "$OpenBSD: syslogd.c,v 1.61 2003/05/17 17:49:28 millert Exp $";
#endif
#endif /* not lint */
@@ -844,7 +844,9 @@ wallmsg(struct filed *f, struct iovec *iov)
while (fread((char *)&ut, sizeof(ut), 1, uf) == 1) {
if (ut.ut_name[0] == '\0')
continue;
- strlcpy(line, ut.ut_line, sizeof(line));
+ /* must use strncpy since ut_* may not be NUL terminated */
+ strncpy(line, ut.ut_line, sizeof(line) - 1);
+ line[sizeof(line) - 1];
if (f->f_type == F_WALL) {
if ((p = ttymsg(iov, 6, line, TTYMSGTIME)) != NULL) {
errno = 0; /* already in msg */