|
|
12745e |
diff -Nru glibc-2.17-c758a686/sysdeps/unix/sysv/linux/tcsetattr.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/tcsetattr.c
|
|
|
12745e |
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/tcsetattr.c 2012-06-05 07:42:49.000000000 -0600
|
|
|
12745e |
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/tcsetattr.c 2012-06-07 12:15:21.831318623 -0600
|
|
|
29e444 |
@@ -48,6 +48,7 @@ tcsetattr (fd, optional_actions, termios
|
|
|
29e444 |
{
|
|
|
29e444 |
struct __kernel_termios k_termios;
|
|
|
29e444 |
unsigned long int cmd;
|
|
|
29e444 |
+ int retval;
|
|
|
29e444 |
|
|
|
29e444 |
switch (optional_actions)
|
|
|
29e444 |
{
|
|
|
29e444 |
@@ -79,6 +80,35 @@ tcsetattr (fd, optional_actions, termios
|
|
|
29e444 |
memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
|
|
|
29e444 |
__KERNEL_NCCS * sizeof (cc_t));
|
|
|
29e444 |
|
|
|
29e444 |
- return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
|
|
|
29e444 |
+ retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
|
|
|
29e444 |
+
|
|
|
29e444 |
+ if (retval == 0 && cmd == TCSETS)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ /* The Linux kernel has a bug which silently ignore the invalid
|
|
|
29e444 |
+ c_cflag on pty. We have to check it here. */
|
|
|
29e444 |
+ int save = errno;
|
|
|
29e444 |
+ retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios);
|
|
|
29e444 |
+ if (retval)
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ /* We cannot verify if the setting is ok. We don't return
|
|
|
29e444 |
+ an error (?). */
|
|
|
29e444 |
+ __set_errno (save);
|
|
|
29e444 |
+ retval = 0;
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+ else if ((termios_p->c_cflag & (PARENB | CREAD))
|
|
|
29e444 |
+ != (k_termios.c_cflag & (PARENB | CREAD))
|
|
|
29e444 |
+ || ((termios_p->c_cflag & CSIZE)
|
|
|
29e444 |
+ && ((termios_p->c_cflag & CSIZE)
|
|
|
29e444 |
+ != (k_termios.c_cflag & CSIZE))))
|
|
|
29e444 |
+ {
|
|
|
29e444 |
+ /* It looks like the Linux kernel silently changed the
|
|
|
29e444 |
+ PARENB/CREAD/CSIZE bits in c_cflag. Report it as an
|
|
|
29e444 |
+ error. */
|
|
|
29e444 |
+ __set_errno (EINVAL);
|
|
|
29e444 |
+ retval = -1;
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+ }
|
|
|
29e444 |
+
|
|
|
29e444 |
+ return retval;
|
|
|
29e444 |
}
|
|
|
29e444 |
libc_hidden_def (tcsetattr)
|