Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 6569 invoked from network); 24 Dec 2007 18:59:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Dec 2007 18:59:18 -0000 Received: (qmail 65118 invoked by uid 500); 24 Dec 2007 18:59:07 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 65100 invoked by uid 500); 24 Dec 2007 18:59:07 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 65091 invoked by uid 99); 24 Dec 2007 18:59:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Dec 2007 10:59:07 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Dec 2007 18:59:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 347F71A9832; Mon, 24 Dec 2007 10:58:54 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r606724 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/DataInputStream.java test/api/common/tests/api/java/io/DataInputStreamTest.java Date: Mon, 24 Dec 2007 18:58:53 -0000 To: commits@harmony.apache.org From: mmarkov@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071224185854.347F71A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mmarkov Date: Mon Dec 24 10:58:51 2007 New Revision: 606724 URL: http://svn.apache.org/viewvc?rev=606724&view=rev Log: Applied patch for HARMONY-5336: [classlib][luni] StackOverflow in DataInputStream.readUTF(DataInput) Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataInputStream.java harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataInputStream.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataInputStream.java?rev=606724&r1=606723&r2=606724&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataInputStream.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/DataInputStream.java Mon Dec 24 10:58:51 2007 @@ -413,10 +413,13 @@ String decodeUTF(int utfSize) throws IOException { + return decodeUTF(utfSize, this); + } + private static String decodeUTF(int utfSize, DataInput in) throws IOException { byte[] buf = new byte[utfSize]; char[] out = new char[utfSize]; - readFully(buf, 0, utfSize); + in.readFully(buf, 0, utfSize); return Util.convertUTF8WithBuf(buf, out, 0, utfSize); } @@ -434,7 +437,7 @@ * @see DataOutput#writeUTF(java.lang.String) */ public static final String readUTF(DataInput in) throws IOException { - return in.readUTF(); + return decodeUTF(in.readUnsignedShort(), in); } /** Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java?rev=606724&r1=606723&r2=606724&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/io/DataInputStreamTest.java Mon Dec 24 10:58:51 2007 @@ -18,6 +18,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.EOFException; @@ -540,6 +541,67 @@ assertTrue("Incorrect string read", dis.readUTF().equals(unihw)); } + static class TestDataInputStream implements DataInput { + public boolean readBoolean() throws IOException { + return false; + } + + public byte readByte() throws IOException { + return (byte) 0; + } + + public char readChar() throws IOException { + return (char) 0; + } + + public double readDouble() throws IOException { + return 0.0; + } + + public float readFloat() throws IOException { + return (float) 0.0; + } + + public void readFully(byte[] buffer) throws IOException { + } + + public void readFully(byte[] buffer, int offset, int count) + throws IOException { + } + + public int readInt() throws IOException { + return 0; + } + + public String readLine() throws IOException { + return null; + } + + public long readLong() throws IOException { + return (long) 0; + } + + public short readShort() throws IOException { + return (short) 0; + } + + public int readUnsignedByte() throws IOException { + return 0; + } + + public int readUnsignedShort() throws IOException { + return 0; + } + + public String readUTF() throws IOException { + return DataInputStream.readUTF(this); + } + + public int skipBytes(int count) throws IOException { + return 0; + } + } + /** * @tests java.io.DataInputStream#readUTF(java.io.DataInput) */ @@ -553,6 +615,9 @@ dis.available() == unihw.length() + 2); assertTrue("Incorrect string read", DataInputStream.readUTF(dis) .equals(unihw)); + + // Regression test for HARMONY-5336 + new TestDataInputStream().readUTF(); } /**