From 10a3b37e900d0f9a36040c7e57e2a7239893fef6 Mon Sep 17 00:00:00 2001 From: Gregory Minshall Date: Tue, 13 May 1986 05:21:20 -0800 Subject: [PATCH] Two bugs. First, ttloop() was not reacting to an EOF on the read from the network. Second, if a wont ttype was coming in it was not causing the ttypopt clock to be set since 1) the setting was in dontoption rather than wontoption and 2) we were leaving hisopts[ttype] equal to OPT_NO. SCCS-vsn: libexec/telnetd/telnetd.c 5.18 --- usr/src/libexec/telnetd/telnetd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/usr/src/libexec/telnetd/telnetd.c b/usr/src/libexec/telnetd/telnetd.c index 3dbdd8056e..2ed0e96af1 100644 --- a/usr/src/libexec/telnetd/telnetd.c +++ b/usr/src/libexec/telnetd/telnetd.c @@ -11,7 +11,7 @@ char copyright[] = #endif not lint #ifndef lint -static char sccsid[] = "@(#)telnetd.c 5.17 (Berkeley) %G%"; +static char sccsid[] = "@(#)telnetd.c 5.18 (Berkeley) %G%"; #endif not lint /* @@ -189,6 +189,10 @@ ttloop() ncc = read(net, netibuf, sizeof netibuf); if (ncc < 0) { syslog(LOG_INFO, "ttloop: read: %m\n"); + exit(1); + } else if (ncc == 0) { + syslog(LOG_INFO, "ttloop: peer died: %m\n"); + exit(1); } netip = netibuf; telrcv(); /* state machine */ @@ -213,6 +217,7 @@ getterminaltype() settimer(getterminal); bcopy(sbuf, nfrontp, sizeof sbuf); nfrontp += sizeof sbuf; + hisopts[TELOPT_TTYPE] = OPT_YES_BUT_ALWAYS_LOOK; while (sequenceIs(ttypeopt, getterminal)) { ttloop(); } @@ -863,7 +868,12 @@ wontoption(option) case TELOPT_BINARY: mode(0, RAW); break; + + case TELOPT_TTYPE: + settimer(ttypeopt); + break; } + fmt = dont; hisopts[option] = OPT_NO; sprintf(nfrontp, fmt, option); @@ -920,11 +930,6 @@ int option; fmt = wont; break; - case TELOPT_TTYPE: - fmt = wont; - settimer(ttypeopt); - break; - default: fmt = wont; break; -- 2.20.1