glibc/glibc-fedora-linux-tcsetattr.patch
Florian Weimer dcf3eeb5c0 Auto-sync with upstream master
Upstream commit: e237357a5a0559dee92261f1914d1fa2cd43a1a8

- Support an arbitrary number of search domains in the stub resolver (#168253)
- Detect and apply /etc/resolv.conf changes in libresolv (#1374239)
- Increase malloc alignment on i386 to 16 (swbz#21120)
- Make RES_ROTATE start with a random name server (swbz#19570)
- Fix tgmath.h totalorder, totalordermag return type (swbz#21687)
- Miscellaneous sys/ucontext.h namespace fixes (swbz#21457)
- Rename struct ucontext tag (swbz#21457)
- Call exit system call directly in clone (swbz#21512)
- powerpc64le: Enable float128
- getaddrinfo: Merge IPv6 addresses and IPv4 addresses (swbz#21295)
- Avoid .symver on common symbols (swbz#21666)
- inet_pton: Reject IPv6 addresses with many leading zeros (swbz#16637)
2017-07-03 21:49:42 +02:00

51 lines
1.7 KiB
Diff

Index: b/sysdeps/unix/sysv/linux/tcsetattr.c
===================================================================
--- a/sysdeps/unix/sysv/linux/tcsetattr.c
+++ b/sysdeps/unix/sysv/linux/tcsetattr.c
@@ -45,6 +45,7 @@ __tcsetattr (int fd, int optional_action
{
struct __kernel_termios k_termios;
unsigned long int cmd;
+ int retval;
switch (optional_actions)
{
@@ -75,7 +76,36 @@ __tcsetattr (int fd, int optional_action
memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
__KERNEL_NCCS * sizeof (cc_t));
- return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
+ retval = INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
+
+ if (retval == 0 && cmd == TCSETS)
+ {
+ /* The Linux kernel has a bug which silently ignore the invalid
+ c_cflag on pty. We have to check it here. */
+ int save = errno;
+ retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios);
+ if (retval)
+ {
+ /* We cannot verify if the setting is ok. We don't return
+ an error (?). */
+ __set_errno (save);
+ retval = 0;
+ }
+ else if ((termios_p->c_cflag & (PARENB | CREAD))
+ != (k_termios.c_cflag & (PARENB | CREAD))
+ || ((termios_p->c_cflag & CSIZE)
+ && ((termios_p->c_cflag & CSIZE)
+ != (k_termios.c_cflag & CSIZE))))
+ {
+ /* It looks like the Linux kernel silently changed the
+ PARENB/CREAD/CSIZE bits in c_cflag. Report it as an
+ error. */
+ __set_errno (EINVAL);
+ retval = -1;
+ }
+ }
+
+ return retval;
}
weak_alias (__tcsetattr, tcsetattr)
libc_hidden_def (tcsetattr)