diff options
author | millert <millert@openbsd.org> | 2015-04-14 02:24:17 +0000 |
---|---|---|
committer | millert <millert@openbsd.org> | 2015-04-14 02:24:17 +0000 |
commit | 65746b0ce6d3eef9e8b7196bbbe03cc7f6b5b9a5 (patch) | |
tree | 20b63479bc3f98fe52348b7867910e0206e21fac /libexec/getty | |
parent | pwd_mkdb now fits onto the install media. no more chroot games. (diff) | |
download | wireguard-openbsd-65746b0ce6d3eef9e8b7196bbbe03cc7f6b5b9a5.tar.xz wireguard-openbsd-65746b0ce6d3eef9e8b7196bbbe03cc7f6b5b9a5.zip |
Log a more useful error message if ttyname() fails. OK deraadt@
Diffstat (limited to 'libexec/getty')
-rw-r--r-- | libexec/getty/main.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libexec/getty/main.c b/libexec/getty/main.c index 4071b140169..24189db141c 100644 --- a/libexec/getty/main.c +++ b/libexec/getty/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.35 2015/01/16 05:53:49 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.36 2015/04/14 02:24:17 millert Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -185,7 +185,15 @@ main(int argc, char *argv[]) * J. Gettys - MIT Project Athena. */ if (argc <= 2 || strcmp(argv[2], "-") == 0) { - snprintf(ttyn, sizeof ttyn, "%s", ttyname(0)); + if ((tname = ttyname(0)) == NULL) { + syslog(LOG_ERR, "stdin: %m"); + exit(1); + } + if (strlcpy(ttyn, tname, sizeof(ttyn)) >= sizeof(ttyn)) { + errno = ENAMETOOLONG; + syslog(LOG_ERR, "%s: %m", tname); + exit(1); + } } else { int i; |