summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2012-12-04 19:31:17 +0000
committerkettenis <kettenis@openbsd.org>2012-12-04 19:31:17 +0000
commit1e9beb47f2946cc4e7432884c17587b68209986f (patch)
tree2879dfcb71839d3ba7dbe2ee4b2c65ef19683bbf
parentEliminate hand-rolled pseudo-strerror() %m strangeness by replacing (diff)
downloadwireguard-openbsd-1e9beb47f2946cc4e7432884c17587b68209986f.tar.xz
wireguard-openbsd-1e9beb47f2946cc4e7432884c17587b68209986f.zip
Get rid of two 10-year-old XXX comments and do check for getchar(3) returning
EOF. Fixes a very annoying bug where cu(1) will start sending the EOF "character" down the serial line at high speed if it loses its input terminal. ok deraadt@, nicm@
-rw-r--r--usr.bin/tip/tip.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c
index 11de8595670..e911cb018f1 100644
--- a/usr.bin/tip/tip.c
+++ b/usr.bin/tip/tip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.c,v 1.53 2010/07/03 03:33:12 nicm Exp $ */
+/* $OpenBSD: tip.c,v 1.54 2012/12/04 19:31:17 kettenis Exp $ */
/* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */
/*
@@ -296,8 +296,10 @@ tipin(void)
}
while (1) {
- gch = getchar()&STRIP_PAR;
- /* XXX does not check for EOF */
+ gch = getchar();
+ if (gch == EOF)
+ cleanup(0);
+ gch &= STRIP_PAR;
if (gch == vgetnum(ESCAPE) && bol) {
if (!noesc) {
if (!(gch = escape()))
@@ -313,8 +315,12 @@ tipin(void)
if (vgetnum(HALFDUPLEX))
printf("\r\n");
continue;
- } else if (!cumode && gch == vgetnum(FORCE))
- gch = getchar() & STRIP_PAR;
+ } else if (!cumode && gch == vgetnum(FORCE)) {
+ gch = getchar();
+ if (gch == EOF)
+ cleanup(0);
+ gch &= STRIP_PAR;
+ }
bol = any(gch, vgetstr(EOL));
if (vgetnum(RAISE) && islower(gch))
gch = toupper(gch);
@@ -338,8 +344,10 @@ escape(void)
esctable_t *p;
char c = vgetnum(ESCAPE);
- gch = (getchar()&STRIP_PAR);
- /* XXX does not check for EOF */
+ gch = getchar();
+ if (gch == EOF)
+ cleanup(0);
+ gch &= STRIP_PAR;
for (p = etable; p->e_char; p++)
if (p->e_char == gch) {
printf("%s", ctrl(c));