From: Ben Gras Date: Mon, 16 Jun 2014 17:27:46 +0000 (+0200) Subject: pty range improvement X-Git-Tag: v3.3.0~190 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/named-checkconf.html?a=commitdiff_plain;h=cbb688a05d9cc9d96083d52467fb13c1231987f3;p=minix.git pty range improvement --- diff --git a/drivers/pty/pty.c b/drivers/pty/pty.c index 541739624..772aa5b09 100644 --- a/drivers/pty/pty.c +++ b/drivers/pty/pty.c @@ -93,6 +93,8 @@ static int pty_master_open(devminor_t minor, int UNUSED(access), tty_t *tp; pty_t *pp; + assert(minor >= PTYPX_MINOR && minor < PTYPX_MINOR + NR_PTYS); + if ((tp = line2tty(minor)) == NULL) return ENXIO; pp = tp->tty_priv; @@ -538,6 +540,8 @@ static int pty_slave_open(tty_t *tp, int UNUSED(try)) /* The tty side has been opened. */ pty_t *pp = tp->tty_priv; + assert(tp->tty_minor >= TTYPX_MINOR && tp->tty_minor < TTYPX_MINOR + NR_PTYS); + /* TTY_ACTIVE may already be set, which would indicate that the slave is * reopened after being fully closed while the master is still open. In that * case TTY_CLOSED will also be set, so clear that one. diff --git a/drivers/pty/tty.c b/drivers/pty/tty.c index ed4f31c9d..48bb90068 100644 --- a/drivers/pty/tty.c +++ b/drivers/pty/tty.c @@ -143,7 +143,7 @@ int main(void) if (OK != chardriver_get_minor(&tty_mess, &line)) continue; - if (line - PTYPX_MINOR < NR_PTYS && + if ((line >= PTYPX_MINOR) && (line < (PTYPX_MINOR + NR_PTYS)) && tty_mess.m_type != CDEV_IOCTL) { /* Terminals and pseudo terminals belong together. We can only * make a distinction between the two based on position in the