This is a diff -u of the two versions of telnetd, I
hope it is more useful.  It still contains the non-IPV6
version of the "login -h" feature code, but I hope the
other two sets of patches are useful.  Our guy may or
may not get time to re-do the -h code, it remains to be
seen.

To recap: telnetd fails to properly handle two-byte IAC
sequences, in particular IAC-IAC, which is how a literal
0xFF is to be passed, which is an emacs M-DEL operation
(delete-backward-word), and IAC-NOP, which can be used as
a session keepalive by things such as putty.  The bracing
of the patched result stinks, the 'owner' of this code
should feel free to improve it.  (We are operating in
minimal differences mode, which is fairly appropriate
for our situation.)

The other feature is to enable SO_KEEPALIVE, and add the
telnetd standard -n option flag to turn it back off if desired.
We were having our embedded system choke up with dead sessions,
SO_KEEPALIVE cleans them out after a time.

-- Jim



-----Original Message-----
From: Denys Vlasenko [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 06, 2008 4:52 PM
To: [email protected]
Cc: Cathey, Jim
Subject: Re: outstanding telnetd bug fix, and two new features

On Thursday 06 November 2008 23:49, Cathey, Jim wrote:
> BB telnetd doesn't properly handle 2-byte IAC
> sequences.  (Both in the 1.10 and 1.11 we've used.)
> The following diff is what we've applied, it fixes
> both IAC-IAC (emacs M-DEL) and IAC-NOP (putty keepalive):
> 
> $ diff -c networking/telnetd.c~ networking/telnetd.c
> *** networking/telnetd.c~    2008-11-04 14:40:31.000000000 -0800
> --- networking/telnetd.c     2008-11-06 14:16:51.000000000 -0800
> ***************
> *** 74,82 ****
>      past (bf + len) then that IAC will be left unprocessed and
> *processed
>      will be less than len.
>   
> -    FIXME - if we mean to send 0xFF to the terminal then it will be
> escaped,
> -    what is the escape character?  We aren't handling that situation
> here.
> - 
>      CR-LF ->'s CR mapping is also done here, for convenience.

Patches are linewrapped. Half of them are not in unidiff format.
Also, interspersing patches and email text makes it
even more difficult to extract apllyable patches.
I'd send one patch per apllet to avoit it, and placed
patch as the very last part of the email, or as an attachment.

I do appreciate your help in making busybox better, but
please resend patches in a more readable form.



+       struct sockaddr_in ir_sin;
+       socklen_t size;
+       char envBuf[32];
+ 
+       size = sizeof(ir_sin);
+ 
+       memset(envBuf,0, sizeof envBuf);
+ 
+       // grab the peer IP address before it's gone
+       if (getpeername(sock, (struct sockaddr *) &ir_sin, &size) < 0) {
+          fprintf(stdout, "%s %d getsockname
error\n\r",__FUNCTION__,__LINE__);
+          bb_perror_msg("getsockname");
+       }
+       else
+       {
+          //fprintf(stdout, "%s %d
0x%s\n\r",__FUNCTION__,__LINE__,inet_ntoa(ir_sin.sin_addr));
+          snprintf(envBuf, sizeof envBuf - 1,
"-h%s",inet_ntoa(ir_sin.sin_addr));
+       }
  
        /*ts->buf1 = (char *)(ts + 1);*/
        /*ts->buf2 = ts->buf1 + BUFSIZE;*/

This is not IPv6 clean. There are many examples of IPv6 capable code
in the tree. Like networking/tftp.c, get_sock_lsa() function.

--
vda

Attachment: udiffs-telnetd.patch
Description: udiffs-telnetd.patch

_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to