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;
/* 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.
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