Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 735 invoked from network); 30 Jan 2009 14:26:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Jan 2009 14:26:24 -0000 Received: (qmail 30105 invoked by uid 500); 30 Jan 2009 14:26:23 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 30021 invoked by uid 500); 30 Jan 2009 14:26:23 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 30010 invoked by uid 99); 30 Jan 2009 14:26:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jan 2009 06:26:23 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jan 2009 14:26:21 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id EC363234C4B3 for ; Fri, 30 Jan 2009 06:25:59 -0800 (PST) Message-ID: <1303986599.1233325559966.JavaMail.jira@brutus> Date: Fri, 30 Jan 2009 06:25:59 -0800 (PST) From: "Martin Oberhuber (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (NET-89) [net] TelnetClient broken for binary transmissions + solution MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12668881#action_12668881 ] Martin Oberhuber commented on NET-89: ------------------------------------- Can we schedule this for fixing in 1.5 and 2.1 by adding following API: {code:title=TelnetClient.java|borderStyle=solid} /** * Enables or disables automatic conversion of input and output streams * to or from NetASCII standard format (CRLF). * By default, automatic conversion is ON. It should be disabled when direct * (binary) access to the data streams is needed. The setting can only * be made or changed before the TelnetClient is connected. * * @param b false to disable automatic conversion of streams to NetASCII format. */ public void setNetASCIIConversion(boolean b); {code} > [net] TelnetClient broken for binary transmissions + solution > ------------------------------------------------------------- > > Key: NET-89 > URL: https://issues.apache.org/jira/browse/NET-89 > Project: Commons Net > Issue Type: Bug > Environment: Operating System: All > Platform: All > Reporter: Colin Surprenant > > TelnetClient does not handle correctly binary transmissions in two places: > First in TelnetClient#_connectAction_() the telnet input and output streams are > wrapped in the NetASCII streams to handle net vs platform line separator > conversion which breaks the binary data. My quick solution was to simply remove > those two wrapping streams. A more general solution might be to provide access > to the unfilterer stream with methods like getUnfilteredInputStream and > getUnfilteredOutputStream or to dynamically stop the NetASCII stream from > 'corrupting' the stream when a TelnetOption.BINARY option is negotiated. > Also, in TelnetInoutStream#__read() there is a bug in the __receiveState > handling for the _STATE_IAC state. When a second consecutive IAC (0x255) is > received to encode the single 0x255 character, read does not return 0x255 but > instead move on to reading the next char in the stream. > The current code reads: > case _STATE_IAC: > switch (ch) > { > case TelnetCommand.WILL: > __receiveState = _STATE_WILL; > continue; > case TelnetCommand.WONT: > __receiveState = _STATE_WONT; > continue; > case TelnetCommand.DO: > __receiveState = _STATE_DO; > continue; > case TelnetCommand.DONT: > __receiveState = _STATE_DONT; > continue; > /* TERMINAL-TYPE option (start)*/ > case TelnetCommand.SB: > __suboption_count = 0; > __receiveState = _STATE_SB; > continue; > /* TERMINAL-TYPE option (end)*/ > case TelnetCommand.IAC: > __receiveState = _STATE_DATA; > break; > default: > break; > } > __receiveState = _STATE_DATA; > continue; > case _STATE_WILL: > but it should be: > case _STATE_IAC: > switch (ch) > { > case TelnetCommand.WILL: > __receiveState = _STATE_WILL; > continue; > case TelnetCommand.WONT: > __receiveState = _STATE_WONT; > continue; > case TelnetCommand.DO: > __receiveState = _STATE_DO; > continue; > case TelnetCommand.DONT: > __receiveState = _STATE_DONT; > continue; > /* TERMINAL-TYPE option (start)*/ > case TelnetCommand.SB: > __suboption_count = 0; > __receiveState = _STATE_SB; > continue; > /* TERMINAL-TYPE option (end)*/ > case TelnetCommand.IAC: > __receiveState = _STATE_DATA; > break; // exit to enclosing switch to return from read > default: > __receiveState = _STATE_DATA; > continue; // move on the next char > } > break; // exit and return from read > case _STATE_WILL: > I'll provide patches for this. > Colin. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.