diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-08-27 06:42:17 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-08-27 06:42:17 +0000 |
commit | 1f2de0ef9f648f2efea7f6bc637963c97c8085f1 (patch) | |
tree | da3075654777cd6cc85d4593a657266baf0d4be3 /lib | |
parent | 2fab4cc75547a72d4b0bfd6623ff7c2f1ff1e6a8 (diff) |
re-initialize the tty buffer with "/dev/" everytime through; spotted by d
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/ttyname.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c index 0c965085e76..192072a208f 100644 --- a/lib/libc/gen/ttyname.c +++ b/lib/libc/gen/ttyname.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: ttyname.c,v 1.4 1997/07/09 00:28:25 millert Exp $"; +static char rcsid[] = "$OpenBSD: ttyname.c,v 1.5 1998/08/27 06:42:16 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -45,7 +45,7 @@ static char rcsid[] = "$OpenBSD: ttyname.c,v 1.4 1997/07/09 00:28:25 millert Exp #include <unistd.h> #include <paths.h> -static char buf[sizeof(_PATH_DEV) + MAXNAMLEN] = _PATH_DEV; +static char buf[sizeof(_PATH_DEV) + MAXNAMLEN]; static char *oldttyname __P((int, struct stat *)); char * @@ -68,6 +68,8 @@ ttyname(fd) if (fstat(fd, &sb) || !S_ISCHR(sb.st_mode)) return (NULL); + memcpy(buf, _PATH_DEV, sizeof(_PATH_DEV)); + if ((db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) { memset(&bkey, 0, sizeof(bkey)); bkey.type = S_IFCHR; @@ -75,8 +77,8 @@ ttyname(fd) key.data = &bkey; key.size = sizeof(bkey); if (!(db->get)(db, &key, &data, 0)) { - bcopy(data.data, - buf + sizeof(_PATH_DEV) - 1, data.size); + memcpy(buf + sizeof(_PATH_DEV) - 1, data.data, + data.size); (void)(db->close)(db); return (buf); } @@ -101,7 +103,7 @@ oldttyname(fd, sb) while ((dirp = readdir(dp))) { if (dirp->d_fileno != sb->st_ino) continue; - bcopy(dirp->d_name, buf + sizeof(_PATH_DEV) - 1, + memcpy(buf + sizeof(_PATH_DEV) - 1, dirp->d_name, dirp->d_namlen + 1); if (stat(buf, &dsb) || sb->st_dev != dsb.st_dev || sb->st_ino != dsb.st_ino) |