diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-05-17 17:49:29 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-05-17 17:49:29 +0000 |
commit | 63cb7e9006604dd26df7a610ef62a2d8dc670fe8 (patch) | |
tree | 8d36807de73d192076978f3dc4689d984330ecd0 /usr.sbin/syslogd | |
parent | f3b81365fc44f6cbac3ecb5e70222c47f5d74a89 (diff) |
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@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 8 |
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 */ |