From owner-svn-src-stable@freebsd.org Tue Dec 3 22:59:56 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A0A091C0E0C; Tue, 3 Dec 2019 22:59:56 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47SHW03nYRz45ZV; Tue, 3 Dec 2019 22:59:56 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 61F201EE3E; Tue, 3 Dec 2019 22:59:56 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB3MxuMx011042; Tue, 3 Dec 2019 22:59:56 GMT (envelope-from vangyzen@FreeBSD.org) Received: (from vangyzen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB3Mxu2D011041; Tue, 3 Dec 2019 22:59:56 GMT (envelope-from vangyzen@FreeBSD.org) Message-Id: <201912032259.xB3Mxu2D011041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vangyzen set sender to vangyzen@FreeBSD.org using -f From: Eric van Gyzen Date: Tue, 3 Dec 2019 22:59:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r355370 - stable/11/usr.bin/tip/tip X-SVN-Group: stable-11 X-SVN-Commit-Author: vangyzen X-SVN-Commit-Paths: stable/11/usr.bin/tip/tip X-SVN-Commit-Revision: 355370 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Dec 2019 22:59:56 -0000 Author: vangyzen Date: Tue Dec 3 22:59:55 2019 New Revision: 355370 URL: https://svnweb.freebsd.org/changeset/base/355370 Log: MFC r354624 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. Sponsored by: Dell EMC Isilon Modified: stable/11/usr.bin/tip/tip/tip.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/tip/tip/tip.c ============================================================================== --- stable/11/usr.bin/tip/tip/tip.c Tue Dec 3 22:57:10 2019 (r355369) +++ stable/11/usr.bin/tip/tip/tip.c Tue Dec 3 22:59:55 2019 (r355370) @@ -250,7 +250,6 @@ cucommon: tipin(); else tipout(); - /*NOTREACHED*/ exit(0); } @@ -400,11 +399,16 @@ tipin(void) } while (1) { - gch = getchar()&STRIP_PAR; - /* XXX does not check for EOF */ + gch = getchar(); + if (gch == EOF) + return; + gch = gch & STRIP_PAR; if ((gch == character(value(ESCAPE))) && bol) { if (!noesc) { - if (!(gch = escape())) + gch = escape(); + if (gch == EOF) + return; + if (gch == 0) continue; } } else if (!cumode && gch == character(value(RAISECHAR))) { @@ -418,7 +422,10 @@ tipin(void) printf("\r\n"); continue; } 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)); if (boolean(value(RAISE)) && islower(gch)) gch = toupper(gch); @@ -442,8 +449,10 @@ escape(void) esctable_t *p; char c = character(value(ESCAPE)); - gch = (getchar()&STRIP_PAR); - /* XXX does not check for EOF */ + gch = getchar(); + if (gch == EOF) + return (EOF); + gch = gch & STRIP_PAR; for (p = etable; p->e_char; p++) if (p->e_char == gch) { if ((p->e_flags&PRIV) && uid)