I forgot Dave Borman's change to keep options up to date (arghh!).
[unix-history] / usr / src / libexec / telnetd / telnetd.c
index 7ac9006..54b867e 100644 (file)
@@ -11,7 +11,7 @@ char copyright[] =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char sccsid[] = "@(#)telnetd.c  5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)telnetd.c  5.11 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -574,10 +574,19 @@ telrcv()
                                continue;
 
                        case WILL:
                                continue;
 
                        case WILL:
+                               state = TS_WILL;
+                               continue;
+
                        case WONT:
                        case WONT:
+                               state = TS_WONT;
+                               continue;
+
                        case DO:
                        case DO:
+                               state = TS_DO;
+                               continue;
+
                        case DONT:
                        case DONT:
-                               state = TS_WILL + (c - WILL);
+                               state = TS_DONT;
                                continue;
 
                        case IAC:
                                continue;
 
                        case IAC:
@@ -639,15 +648,15 @@ willoption(option)
 
        case TELOPT_BINARY:
                mode(RAW, 0);
 
        case TELOPT_BINARY:
                mode(RAW, 0);
-               goto common;
+               fmt = doopt;
+               break;
 
        case TELOPT_ECHO:
                mode(0, ECHO|CRMOD);
 
        case TELOPT_ECHO:
                mode(0, ECHO|CRMOD);
-               /*FALL THRU*/
+               fmt = doopt;
+               break;
 
        case TELOPT_SGA:
 
        case TELOPT_SGA:
-       common:
-               hisopts[option] = 1;
                fmt = doopt;
                break;
 
                fmt = doopt;
                break;
 
@@ -659,6 +668,11 @@ willoption(option)
                fmt = dont;
                break;
        }
                fmt = dont;
                break;
        }
+       if (fmt == doopt) {
+               hisopts[option] = 1;
+       } else {
+               hisopts[option] = 0;
+       }
        sprintf(nfrontp, fmt, option);
        nfrontp += sizeof (dont) - 2;
 }
        sprintf(nfrontp, fmt, option);
        nfrontp += sizeof (dont) - 2;
 }
@@ -669,24 +683,16 @@ wontoption(option)
        char *fmt;
 
        switch (option) {
        char *fmt;
 
        switch (option) {
-
        case TELOPT_ECHO:
                mode(ECHO|CRMOD, 0);
        case TELOPT_ECHO:
                mode(ECHO|CRMOD, 0);
-               goto common;
+               break;
 
        case TELOPT_BINARY:
                mode(0, RAW);
 
        case TELOPT_BINARY:
                mode(0, RAW);
-               /*FALL THRU*/
-
-       case TELOPT_SGA:
-       common:
-               hisopts[option] = 0;
-               fmt = dont;
                break;
                break;
-
-       default:
-               fmt = dont;
        }
        }
+       fmt = dont;
+       hisopts[option] = 0;
        sprintf(nfrontp, fmt, option);
        nfrontp += sizeof (doopt) - 2;
 }
        sprintf(nfrontp, fmt, option);
        nfrontp += sizeof (doopt) - 2;
 }
@@ -704,14 +710,15 @@ dooption(option)
 
        case TELOPT_ECHO:
                mode(ECHO|CRMOD, 0);
 
        case TELOPT_ECHO:
                mode(ECHO|CRMOD, 0);
-               goto common;
+               fmt = will;
+               break;
 
        case TELOPT_BINARY:
                mode(RAW, 0);
 
        case TELOPT_BINARY:
                mode(RAW, 0);
-               /*FALL THRU*/
+               fmt = will;
+               break;
 
        case TELOPT_SGA:
 
        case TELOPT_SGA:
-       common:
                fmt = will;
                break;
 
                fmt = will;
                break;
 
@@ -719,6 +726,11 @@ dooption(option)
                fmt = wont;
                break;
        }
                fmt = wont;
                break;
        }
+       if (fmt == will) {
+           myopts[option] = 1;
+       } else {
+           myopts[option] = 0;
+       }
        sprintf(nfrontp, fmt, option);
        nfrontp += sizeof (doopt) - 2;
 }
        sprintf(nfrontp, fmt, option);
        nfrontp += sizeof (doopt) - 2;
 }