Two bugs. First, ttloop() was not reacting to an EOF on the
authorGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Tue, 13 May 1986 13:21:20 +0000 (05:21 -0800)
committerGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Tue, 13 May 1986 13:21:20 +0000 (05:21 -0800)
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

index 3dbdd80..2ed0e96 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #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
 
 /*
 #endif not lint
 
 /*
@@ -189,6 +189,10 @@ ttloop()
     ncc = read(net, netibuf, sizeof netibuf);
     if (ncc < 0) {
        syslog(LOG_INFO, "ttloop:  read: %m\n");
     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 */
     }
     netip = netibuf;
     telrcv();                  /* state machine */
@@ -213,6 +217,7 @@ getterminaltype()
     settimer(getterminal);
     bcopy(sbuf, nfrontp, sizeof sbuf);
     nfrontp += sizeof sbuf;
     settimer(getterminal);
     bcopy(sbuf, nfrontp, sizeof sbuf);
     nfrontp += sizeof sbuf;
+    hisopts[TELOPT_TTYPE] = OPT_YES_BUT_ALWAYS_LOOK;
     while (sequenceIs(ttypeopt, getterminal)) {
        ttloop();
     }
     while (sequenceIs(ttypeopt, getterminal)) {
        ttloop();
     }
@@ -863,7 +868,12 @@ wontoption(option)
        case TELOPT_BINARY:
                mode(0, RAW);
                break;
        case TELOPT_BINARY:
                mode(0, RAW);
                break;
+
+       case TELOPT_TTYPE:
+           settimer(ttypeopt);
+           break;
        }
        }
+
        fmt = dont;
        hisopts[option] = OPT_NO;
        sprintf(nfrontp, fmt, option);
        fmt = dont;
        hisopts[option] = OPT_NO;
        sprintf(nfrontp, fmt, option);
@@ -920,11 +930,6 @@ int option;
        fmt = wont;
        break;
 
        fmt = wont;
        break;
 
-    case TELOPT_TTYPE:
-       fmt = wont;
-       settimer(ttypeopt);
-       break;
-
     default:
        fmt = wont;
        break;
     default:
        fmt = wont;
        break;