Source-Changes-HG archive

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

[src/trunk]: src/sys/kern PR/41673: Stathis Kamperis: tcsetpgrp returns EINVA...



details:   https://anonhg.NetBSD.org/src/rev/f705dd1e2c04
branches:  trunk
changeset: 778017:f705dd1e2c04
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 12 18:27:08 2012 +0000

description:
PR/41673: Stathis Kamperis: tcsetpgrp returns EINVAL, but should return EPERM.

diffstat:

 sys/kern/tty.c |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (52 lines):

diff -r 0753b4c6bb7d -r f705dd1e2c04 sys/kern/tty.c
--- a/sys/kern/tty.c    Mon Mar 12 18:17:12 2012 +0000
+++ b/sys/kern/tty.c    Mon Mar 12 18:27:08 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.249 2011/10/21 02:08:09 christos Exp $       */
+/*     $NetBSD: tty.c,v 1.250 2012/03/12 18:27:08 christos Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.249 2011/10/21 02:08:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.250 2012/03/12 18:27:08 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1271,7 +1271,7 @@
                mutex_exit(proc_lock);
                break;
        case FIOSETOWN: {               /* set pgrp of tty */
-               pid_t pgid = *(int *)data;
+               pid_t pgid = *(pid_t *)data;
                struct pgrp *pgrp;
 
                mutex_enter(proc_lock); 
@@ -1308,18 +1308,18 @@
        }
        case TIOCSPGRP: {               /* set pgrp of tty */
                struct pgrp *pgrp;
+               pid_t pgid = *(pid_t *)data;
+
+               if (pgid == NO_PGID)
+                       return EINVAL;
 
                mutex_enter(proc_lock); 
                if (!isctty(p, tp)) {
                        mutex_exit(proc_lock);
                        return (ENOTTY);
                }
-               pgrp = pgrp_find(*(pid_t *)data);
-               if (pgrp == NULL) {
-                       mutex_exit(proc_lock);
-                       return (EINVAL);
-               }
-               if (pgrp->pg_session != p->p_session) {
+               pgrp = pgrp_find(pgid);
+               if (pgrp == NULL || pgrp->pg_session != p->p_session) {
                        mutex_exit(proc_lock);
                        return (EPERM);
                }



Home | Main Index | Thread Index | Old Index