Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 93861 invoked from network); 8 Mar 2010 10:17:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Mar 2010 10:17:15 -0000 Received: (qmail 18282 invoked by uid 500); 8 Mar 2010 10:16:51 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 18106 invoked by uid 500); 8 Mar 2010 10:16:51 -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 18098 invoked by uid 99); 8 Mar 2010 10:16:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Mar 2010 10:16:50 +0000 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; Mon, 08 Mar 2010 10:16:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 42CEA234C1EF for ; Mon, 8 Mar 2010 10:16:27 +0000 (UTC) Message-ID: <982657073.133021268043387272.JavaMail.jira@brutus.apache.org> Date: Mon, 8 Mar 2010 10:16:27 +0000 (UTC) From: "Rory Winston (JIRA)" To: issues@commons.apache.org Subject: [jira] Closed: (NET-290) DotTerminatedMessageReader does not parse \r \r \n correctly In-Reply-To: <1283589459.1250709014878.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Rory Winston closed NET-290. ---------------------------- Resolution: Fixed Fix Version/s: 2.1 Thanks Jonathan - well spotted and fix applied. > DotTerminatedMessageReader does not parse \r \r \n correctly > ------------------------------------------------------------ > > Key: NET-290 > URL: https://issues.apache.org/jira/browse/NET-290 > Project: Commons Net > Issue Type: Bug > Affects Versions: 2.0 > Environment: RedHat Linux > Linux XXX 2.6.18-128.2.1.el5 #1 SMP Wed Jul 8 11:54:47 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux > java version "1.6.0" > OpenJDK Runtime Environment (build 1.6.0-b09) > OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode) > Reporter: Jonathan Baker > Fix For: 2.1 > > > If the DotTerminatedMessageReader receives two carriage return characters at the end of the line, it does not process them correctly. > When the DTMR tries to read "\r\r\n" from the server, it does not process this as a correct end of line. The code handles the first \r as a standalone character, but then does not process the second \r character to test for end-of-line. If this happens at the end of a file, the DTMR will not recognize the '.' character as the end of file, and will try to read another character. This hangs the reader. > The process flow breaks down in the following order. The first \r character is tested at line 127. It then reads the second \r character at line 133. The test fails, and the second \r is pushed in to the internalBuffer at line 160. The second time the read() method is called, the \r character is returned without processing at line 90. The third time the read() is called, the \n character is read and checked at line 127. But, because the preceding \r character is not found first, it does not process this as EOL. If the next character is a '.', it is not processed as EOF. > The following fix solves the problem by pushing the second \r character back in to the reader stream (rather than putting it in the internalBuffer), where it will be processed correctly: > 160a160,163 > > else if ( ch == '\r' ) > > { > > internalReader.unread( ch ); > > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.