From owner-freebsd-bugs Wed Dec 4 12:40: 8 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7DD6D37B401 for ; Wed, 4 Dec 2002 12:40:05 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E805743ECD for ; Wed, 4 Dec 2002 12:40:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gB4Ke3x3045481 for ; Wed, 4 Dec 2002 12:40:03 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gB4Ke33V045480; Wed, 4 Dec 2002 12:40:03 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7BCE637B401 for ; Wed, 4 Dec 2002 12:36:20 -0800 (PST) Received: from mailhost.stack.nl (vaak.stack.nl [131.155.140.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6777443E88 for ; Wed, 4 Dec 2002 12:36:19 -0800 (PST) (envelope-from marcolz@stack.nl) Received: by mailhost.stack.nl (Postfix, from userid 65534) id 0C09860F08; Wed, 4 Dec 2002 21:36:18 +0100 (CET) Received: from toad.stack.nl (toad.stack.nl [2001:610:1108:5010:202:b3ff:fe17:9e1a]) by mailhost.stack.nl (Postfix) with ESMTP id 8E06960EC5; Wed, 4 Dec 2002 21:36:09 +0100 (CET) Received: by toad.stack.nl (Postfix, from userid 333) id 38A43961C; Wed, 4 Dec 2002 21:36:09 +0100 (CET) Message-Id: <20021204203609.GA26229@stack.nl> Date: Wed, 4 Dec 2002 21:36:09 +0100 From: Marc Olzheim , Jan Willem Knopper , Dean Strik Reply-To: Marc Olzheim , Jan Willem Knopper , Dean Strik To: FreeBSD-gnats-submit@FreeBSD.org Cc: Marc Olzheim , Jan Willem Knopper , Dean Strik X-Send-Pr-Version: 3.113 Subject: bin/45995: Telnet fails to properly handle SIGPIPE on its terminal. Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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