tip/cu: check for EOF on input on the local side
If cu reads an EOF on the input side, it goes into a tight loop sending a garbage byte to the remote. With this change, it exits gracefully, along with its child. MFC after: 2 weeks Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
a2e7a62d8f
commit
9d8c51675c
@ -252,7 +252,6 @@ main(int argc, char *argv[])
|
|||||||
tipin();
|
tipin();
|
||||||
else
|
else
|
||||||
tipout();
|
tipout();
|
||||||
/*NOTREACHED*/
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,11 +401,16 @@ tipin(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
gch = getchar()&STRIP_PAR;
|
gch = getchar();
|
||||||
/* XXX does not check for EOF */
|
if (gch == EOF)
|
||||||
|
return;
|
||||||
|
gch = gch & STRIP_PAR;
|
||||||
if ((gch == character(value(ESCAPE))) && bol) {
|
if ((gch == character(value(ESCAPE))) && bol) {
|
||||||
if (!noesc) {
|
if (!noesc) {
|
||||||
if (!(gch = escape()))
|
gch = escape();
|
||||||
|
if (gch == EOF)
|
||||||
|
return;
|
||||||
|
if (gch == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (!cumode && gch == character(value(RAISECHAR))) {
|
} else if (!cumode && gch == character(value(RAISECHAR))) {
|
||||||
@ -420,7 +424,10 @@ tipin(void)
|
|||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
continue;
|
continue;
|
||||||
} else if (!cumode && gch == character(value(FORCE)))
|
} else if (!cumode && gch == character(value(FORCE)))
|
||||||
gch = getchar()&STRIP_PAR;
|
gch = getchar();
|
||||||
|
if (gch == EOF)
|
||||||
|
return;
|
||||||
|
gch = gch & STRIP_PAR;
|
||||||
bol = any(gch, value(EOL));
|
bol = any(gch, value(EOL));
|
||||||
if (boolean(value(RAISE)) && islower(gch))
|
if (boolean(value(RAISE)) && islower(gch))
|
||||||
gch = toupper(gch);
|
gch = toupper(gch);
|
||||||
@ -444,8 +451,10 @@ escape(void)
|
|||||||
esctable_t *p;
|
esctable_t *p;
|
||||||
char c = character(value(ESCAPE));
|
char c = character(value(ESCAPE));
|
||||||
|
|
||||||
gch = (getchar()&STRIP_PAR);
|
gch = getchar();
|
||||||
/* XXX does not check for EOF */
|
if (gch == EOF)
|
||||||
|
return (EOF);
|
||||||
|
gch = gch & STRIP_PAR;
|
||||||
for (p = etable; p->e_char; p++)
|
for (p = etable; p->e_char; p++)
|
||||||
if (p->e_char == gch) {
|
if (p->e_char == gch) {
|
||||||
if ((p->e_flags&PRIV) && uid)
|
if ((p->e_flags&PRIV) && uid)
|
||||||
|
Loading…
Reference in New Issue
Block a user