Skip to content

Commit

Permalink
pty: return EINVAL for TIOCGPTN for BSD ptys
Browse files Browse the repository at this point in the history
Commit bbb63c5 (drivers:tty:fix up
ENOIOCTLCMD error handling) changed the default return value from tty
ioctl to be ENOTTY and not EINVAL. This is appropriate.

But in case of TIOCGPTN for the old BSD ptys glibc started failing
because it expects EINVAL to be returned. Only then it continues to
obtain the pts name the other way around.

So fix this case by explicit return of EINVAL in this case.

Signed-off-by: Jiri Slaby <[email protected]>
Reported-by: Florian Westphal <[email protected]>
Cc: Alan Cox <[email protected]>
Cc: stable <[email protected]> # 3.7+
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jiri Slaby authored and gregkh committed Jan 17, 2013
1 parent 5dd070d commit ded2f29
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/tty/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ static int pty_bsd_ioctl(struct tty_struct *tty,
return pty_get_pktmode(tty, (int __user *)arg);
case TIOCSIG: /* Send signal to other side of pty */
return pty_signal(tty, (int) arg);
case TIOCGPTN: /* TTY returns ENOTTY, but glibc expects EINVAL here */
return -EINVAL;
}
return -ENOIOCTLCMD;
}
Expand Down

0 comments on commit ded2f29

Please sign in to comment.