Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/write PR/28474: Geoff C. Wing: write does some weird...



details:   https://anonhg.NetBSD.org/src/rev/ee2ffdeb1534
branches:  trunk
changeset: 571539:ee2ffdeb1534
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Nov 30 04:08:38 2004 +0000

description:
PR/28474: Geoff C. Wing: write does some weird checking and can't handle ptyfs

diffstat:

 usr.bin/write/term_chk.c |  11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diffs (46 lines):

diff -r 2daf60979510 -r ee2ffdeb1534 usr.bin/write/term_chk.c
--- a/usr.bin/write/term_chk.c  Tue Nov 30 03:08:27 2004 +0000
+++ b/usr.bin/write/term_chk.c  Tue Nov 30 04:08:38 2004 +0000
@@ -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 @@
        struct stat s;
        int i, fd, serrno;
 
-       if (strcspn(tty, "./") != strlen(tty)) {
+       if (strstr(tty, "../") != NULL) {
                errno = EINVAL;
                return -1;
        }
@@ -111,7 +111,6 @@
        int myttyfd;
        int msgsok;
        char *mytty;
-       char *cp;
 
        /* check that sender has write enabled */
        if (isatty(fileno(stdin)))
@@ -126,8 +125,8 @@
                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) {



Home | Main Index | Thread Index | Old Index