Bug 2569 - Telnet client doesn't strip NUL when server sends CR/NUL as end-of-line
Summary: Telnet client doesn't strip NUL when server sends CR/NUL as end-of-line
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Networking (show other bugs)
Version: 1.16.x
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-17 09:29 UTC by Nick Leverton
Modified: 2010-10-29 00:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Fix telnet.c to convert CR/NUL end-of-lines into bare CR. (1009 bytes, patch)
2010-09-17 09:29 UTC, Nick Leverton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Leverton 2010-09-17 09:29:03 UTC
Created attachment 2473 [details]
Fix telnet.c to convert CR/NUL end-of-lines into bare CR.

When operating with a telnet server that appends NUL to transmitted CRs, busybox telnet client doesn't remove the NUL again.

Netkit telnetd (Linux) does this to a bare CR but not to CR/LF, which means that it rarely shows up when talking to a shell based system with cooked I/O.  However telnetting to another embedded device I have here - operating system unknown - echoes a CR/NUL in response every time I send a \r.

This is a problem for me as I am using busybox telnet to script a session with the device, and the NULs mean that 'empty' (http://empty.sourceforge.net) wrongly assumes end of string.

It seems from RFC1123 section 3.3.1, on telnet interoperability practices,  that CR/NUL is an end of line indication and the NUL should not be passed onto applications.  Certainly netkit-telnet client removes the NUL from a CR/NUL.

The attached patch fixes busybox telnet.c to work like netkit-telnet, which removes the NUL but passes the alternative End-of-line representation of CR/LF through unchanged.

Patch should apply to 1.17 as well with a slight offset.  Hopefully I have filed this against the correct product this time !
Comment 1 Denys Vlasenko 2010-10-29 00:13:30 UTC
Thanks for your work.

Your patch mishandles CR IAC and CR CR NUL sequences, though.

I reworked it and applied the fix to git.