summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Marie <semarie@cvs.openbsd.org>2015-11-29 14:18:41 +0000
committerSebastien Marie <semarie@cvs.openbsd.org>2015-11-29 14:18:41 +0000
commitfaf2c2a6a7291f57d6e618b62d638bcd08460d7d (patch)
tree89dabd9b63c454f059a2d1a4af43796f0b7fe150
parent02bda760051dbe85a8ebda9cc6e71f2dfa066627 (diff)
telnet: check if fd is a tty before calling tcsetattr(fd, TCSADRAIN)
ok deraadt@
-rw-r--r--usr.bin/telnet/sys_bsd.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c
index 16249f13e66..173fe79ea0f 100644
--- a/usr.bin/telnet/sys_bsd.c
+++ b/usr.bin/telnet/sys_bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_bsd.c,v 1.30 2015/03/29 13:42:53 sthen Exp $ */
+/* $OpenBSD: sys_bsd.c,v 1.31 2015/11/29 14:18:40 semarie Exp $ */
/* $NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $ */
/*
@@ -266,7 +266,8 @@ TerminalNewMode(int f)
/*
* Wait for data to drain, then flush again.
*/
- tcsetattr(tin, TCSADRAIN, &tmp_tc);
+ if (isatty(tin))
+ tcsetattr(tin, TCSADRAIN, &tmp_tc);
old = ttyflush(SYNCHing|flushout);
} while (old < 0 || old > 1);
}
@@ -414,7 +415,7 @@ TerminalNewMode(int f)
sigprocmask(SIG_UNBLOCK, &mask, NULL);
tmp_tc = old_tc;
}
- if (tcsetattr(tin, TCSADRAIN, &tmp_tc) < 0)
+ if (isatty(tin) && tcsetattr(tin, TCSADRAIN, &tmp_tc) < 0)
tcsetattr(tin, TCSANOW, &tmp_tc);
ioctl(tin, FIONBIO, &onoff);