From 9f5156939d103f5d7b35348a398089334054058a Mon Sep 17 00:00:00 2001 From: Gregory Minshall Date: Wed, 9 Apr 1986 16:18:27 -0800 Subject: [PATCH] This version does various flavors of CR-LF, CR-NULL, etc., correctly. SCCS-vsn: libexec/telnetd/telnetd.c 5.8 --- usr/src/libexec/telnetd/telnetd.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/usr/src/libexec/telnetd/telnetd.c b/usr/src/libexec/telnetd/telnetd.c index 58c0d4c2cf..a92b52b2f1 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.7 (Berkeley) %G%"; +static char sccsid[] = "@(#)telnetd.c 5.8 (Berkeley) %G%"; #endif not lint /* @@ -260,6 +260,13 @@ telnet(f, p) if (c == IAC) *nfrontp++ = c; *nfrontp++ = c; + if (c == '\r') { + if (pcc > 0 && ((*ptyip & 0377) == '\n')) { + *nfrontp++ = *ptyip++ & 0377; + pcc--; + } else + *nfrontp++ = '\0'; + } } if ((obits & (1 << f)) && (nfrontp - nbackp) > 0) netflush(); @@ -310,8 +317,20 @@ telrcv() } if (inter > 0) break; + /* + * We map \r\n ==> \n, since \r\n says + * that we want to be in column 1 of the next + * printable line, and \n is the standard + * unix way of saying that (\r is only good + * if CRMOD is set, which it normally is). + */ if (!myopts[TELOPT_BINARY] && c == '\r') { - state = TS_CR; + if ((ncc > 0) && ('\n' == *netip)) { + netip++; ncc--; + c = '\n'; + } else { + state = TS_CR; + } } *pfrontp++ = c; break; -- 2.20.1