diff options
| author | christos <christos@NetBSD.org> | 2004-11-30 04:08:38 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2004-11-30 04:08:38 +0000 |
| commit | 67a132acdc60426ed7d79d602cb82176b0df5edf (patch) | |
| tree | 0b3ca5c9bdd4931bc01763debd2e77d6effb72ae /usr.bin/write | |
| parent | 87dda823cf412f2fd0107117fb0ac4edb1e51090 (diff) | |
PR/28474: Geoff C. Wing: write does some weird checking and can't handle ptyfs
Diffstat (limited to 'usr.bin/write')
| -rw-r--r-- | usr.bin/write/term_chk.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/write/term_chk.c b/usr.bin/write/term_chk.c index cfed7ea7b7f..468b3359a1c 100644 --- a/usr.bin/write/term_chk.c +++ b/usr.bin/write/term_chk.c @@ -1,4 +1,4 @@ -/* $NetBSD: term_chk.c,v 1.6 2004/10/27 17:48:47 christos Exp $ */ +/* $NetBSD: term_chk.c,v 1.7 2004/11/30 04:08:38 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -34,7 +34,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: term_chk.c,v 1.6 2004/10/27 17:48:47 christos Exp $"); +__RCSID("$NetBSD: term_chk.c,v 1.7 2004/11/30 04:08:38 christos Exp $"); #endif #include <sys/types.h> @@ -63,7 +63,7 @@ term_chk(uid_t uid, const char *tty, int *msgsokP, time_t *atimeP, int ismytty, struct stat s; int i, fd, serrno; - if (strcspn(tty, "./") != strlen(tty)) { + if (strstr(tty, "../") != NULL) { errno = EINVAL; return -1; } @@ -111,7 +111,6 @@ check_sender(time_t *atime, uid_t myuid, gid_t saved_egid) int myttyfd; int msgsok; char *mytty; - char *cp; /* check that sender has write enabled */ if (isatty(fileno(stdin))) @@ -126,8 +125,8 @@ check_sender(time_t *atime, uid_t myuid, gid_t saved_egid) errx(1, "Cannot find your tty"); if ((mytty = ttyname(myttyfd)) == NULL) err(1, "Cannot find the name of your tty"); - if ((cp = strrchr(mytty, '/')) != NULL) - mytty = cp + 1; + if (strncmp(mytty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) + mytty += sizeof(_PATH_DEV) - 1; if (term_chk(myuid, mytty, &msgsok, atime, 1, saved_egid) == -1) err(1, "%s%s", _PATH_DEV, mytty); if (!msgsok) { |
