bostic@OKEEFFE.BERKELEY.EDU (Keith Bostic) (09/17/87)
Subject: fix for telnetd CR-NL mapping
Index: etc/telnetd.c 4.3BSD
Description:
In order to resolve certain compatibility problems when telnet
sessions are nested, 4.3BSD telnetd has been changed to translate
<CR><NL> to '\r' rather than '\n'. This circumvents problems when
using a telnet client that is incapable of sending <CR><NUL> to
signify a carriage return, then using telnet or tip to connect to
a system that differentiates between carriage return and line feed.
(See previous discussions on the tcp-ip mailing list.) This patch
also fixes an error that mapped <CR><NUL> to '\r' in binary mode.
It is recommended that all 4.3BSD sites change telnetd according
to this patch.
Repeat-By:
See above.
Fix:
Apply following patch.
*** /nbsd/usr/src/etc/telnetd.c Mon May 12 22:21:51 1986
--- telnetd.c Wed Sep 2 23:22:30 1987
***************
*** 13,15 ****
#ifndef lint
! static char sccsid[] = "@(#)telnetd.c 5.18 (Berkeley) 5/12/86";
#endif not lint
--- 13,15 ----
#ifndef lint
! static char sccsid[] = "@(#)telnetd.c 5.20 (Berkeley) 9/2/87";
#endif not lint
***************
*** 573,575 ****
*nfrontp++ = c;
! if (c == '\r') {
if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
--- 573,576 ----
*nfrontp++ = c;
! /* Don't do CR-NUL if we are in binary mode */
! if ((c == '\r') && (myopts[TELOPT_BINARY] == OPT_NO)) {
if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
***************
*** 617,618 ****
--- 618,620 ----
state = TS_DATA;
+ /* Strip off \n or \0 after a \r */
if ((c == 0) || (c == '\n')) {
***************
*** 630,632 ****
/*
! * We map \r\n ==> \n, since \r\n says
* that we want to be in column 1 of the next
--- 632,638 ----
/*
! * We now map \r\n ==> \r for pragmatic reasons.
! * Many client implementations send \r\n when
! * the user hits the CarriageReturn key.
! *
! * We USED to map \r\n ==> \n, since \r\n says
* that we want to be in column 1 of the next
***************
*** 636,644 ****
*/
! if ((myopts[TELOPT_BINARY] == OPT_NO) && c == '\r') {
! if ((ncc > 0) && ('\n' == *netip)) {
! netip++; ncc--;
! c = '\n';
! } else {
! state = TS_CR;
! }
}
--- 642,645 ----
*/
! if ((c == '\r') && (hisopts[TELOPT_BINARY] == OPT_NO)) {
! state = TS_CR;
}