bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-inetutils] Extra null bytes appearing in telnetd


From: Byron Stanoszek
Subject: [bug-inetutils] Extra null bytes appearing in telnetd
Date: Sat, 19 May 2007 13:05:15 -0400 (EDT)

On Linux, I've noticed lately that each output buffer transmitted by telnetd to
the client is preceded by a null byte. This might be something specific to the
Linux pty device or termio settings, but I don't know as I've not been able to
test on other OSes.

During large transmissions such as an 'ls -l' command, these null bytes appear
randomly througout the transmission. Sometimes they appear in the middle of an
ANSI escape sequence, thereby causing different colors or extra characters to
show on the client. The telnetd from the netkit package does not have this
problem.

The following patch to telnetd/telnetd.c fixes the problem by ignoring the
first byte of each output buffer. The second part of the patch also inhibits a
null byte from being generated after a CR (but not CRLF), but this might be
intended behavior so apply conditionally. Again this has not been tested on
other OSes besides Linux and I'm curious to know if the problem is actually
Linux-specific or if anyone else has seen it.


diff -urN inetutils-1.5.orig/telnetd/telnetd.c inetutils-1.5/telnetd/telnetd.c
--- inetutils-1.5.orig/telnetd/telnetd.c        2006-10-11 19:35:10.000000000 
-0400
+++ inetutils-1.5/telnetd/telnetd.c     2007-05-19 12:06:45.000000000 -0400
@@ -639,6 +639,10 @@

        }

+      /* Eat the first character in the buffer */
+      if (pty_input_level () > 0)
+        pty_get_char (0);
+
       while (pty_input_level () > 0)
        {
          if (net_buffer_is_full ())
@@ -651,8 +655,6 @@
            {
              if (pty_input_level () > 0 && pty_get_char (1) == '\n')
                net_output_byte (pty_get_char (0));
-             else
-               net_output_byte (0);
            }
        }


My terminal settings:

speed 38400 baud; rows 36; columns 103; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; 
swtch = <undef>;
start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = 
^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff 
-iuclc -ixany -imaxbel
-iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt 
echoctl echoke

Linux version: 2.6.20.3

 -Byron

--
Byron Stanoszek                         Ph: (330) 644-3059
Systems Programmer                      Fax: (330) 644-8110
Commercial Timesharing Inc.             Email: address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]