pty range improvement

This commit is contained in:
Ben Gras 2014-06-16 19:27:46 +02:00 committed by Lionel Sambuc
parent b41d3ab74e
commit cbb688a05d
2 changed files with 5 additions and 1 deletions

View file

@ -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.

View file

@ -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