Date: Wed, 4 Dec 2002 21:36:09 +0100 From: Marc Olzheim <marcolz@stack.nl>, Jan Willem Knopper <jwk@stack.nl>, Dean Strik <dean@stack.nl> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Marc Olzheim <marcolz@stack.nl>, Jan Willem Knopper <jwk@stack.nl>, Dean Strik <dean@stack.nl> Subject: bin/45995: Telnet fails to properly handle SIGPIPE on its terminal. Message-ID: <20021204203609.GA26229@stack.nl>
next in thread | raw e-mail | index | archive | help
>Number: 45995
>Category: bin
>Synopsis: Telnet fails to properly handle SIGPIPE on its terminal.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Dec 04 12:40:03 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Marc Olzheim, Jan Willem Knopper, Dean Strik
>Release: FreeBSD 2.x-5.x
>Organization:
M.C.G.V. Stack
>Environment:
System: FreeBSD toad.stack.nl 4.7-STABLE FreeBSD 4.7-STABLE #0: Wed Nov 13 20:17:40 CET 2002 marcolz@vwww.stack.nl:/vwww.mnt/triceratops/sources/4.x/sys/compile/toad_vwww i386
>Description:
When telnet's terminal-output is a pipe and when that pipe is
closed, before telnet has flushed it's buffer, it will endlessly
keep trying to flush it anyway, resulting in an 100% cpu eating
telnet.
>How-To-Repeat:
telnet to a port giving more than one line of output and pipe it
through grep -q on something that occurs in thar output. For
example:
telnet mud.stack.nl 3333 | grep -q a8888b
>Fix:
Patch attached:
--WIyZ46R2i8wDzkSu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="telnet.patch"
--- /usr/src/usr.bin/telnet/externs.h Wed Dec 4 21:06:27 2002
+++ /usr/src/usr.bin/telnet/externs.h Wed Dec 4 21:14:14 2002
@@ -263,6 +263,7 @@
tel_leave_binary(int),
TerminalFlushOutput(void),
TerminalNewMode(int),
+ TerminalPanic(void),
TerminalRestoreState(void),
TerminalSaveState(void),
TerminalDefaultChars(void),
--- /usr/src/usr.bin/telnet/sys_bsd.c Wed Dec 4 21:01:44 2002
+++ /usr/src/usr.bin/telnet/sys_bsd.c Wed Dec 4 21:13:56 2002
@@ -131,6 +131,12 @@
errno = 0;
}
+void
+TerminalPanic()
+{
+ (void) intr2(0);
+}
+
int
TerminalWrite(char *buf, int n)
{
--- /usr/src/usr.bin/telnet/terminal.c Wed Dec 4 20:57:34 2002
+++ /usr/src/usr.bin/telnet/terminal.c Wed Dec 4 21:16:16 2002
@@ -148,7 +148,13 @@
ring_consumed(&ttyoring, n);
}
if (n < 0)
+ {
+ /* If flushing the terminal is no longer possible, panic !
+ */
+ if (EPIPE == errno)
+ TerminalPanic();
return -1;
+ }
if (n == n0) {
if (n0)
return -1;
--WIyZ46R2i8wDzkSu--
>Release-Note:
>Audit-Trail:
>Unformatted:
--WIyZ46R2i8wDzkSu
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021204203609.GA26229>
