harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r431544 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni: net/PlainSocketImpl.java util/ExternalMessages.properties
Date Tue, 15 Aug 2006 07:04:42 GMT
Author: pyang
Date: Tue Aug 15 00:04:42 2006
New Revision: 431544

URL: http://svn.apache.org/viewvc?rev=431544&view=rev
Log:
Patch applied for HARMONY-1164 ( [classlib][luni] java.net.Socket.connect throws unexpected
ArrayIndexOutOfBoundsException when the proxy server replies malformed message.)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java?rev=431544&r1=431543&r2=431544&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
Tue Aug 15 00:04:42 2006
@@ -558,14 +558,21 @@
 	 * Read a SOCKS V4 reply.
 	 */
 	private Socks4Message socksReadReply() throws IOException {
-		Socks4Message reply = new Socks4Message();
-		int bytesRead = 0;
-		while (bytesRead < Socks4Message.REPLY_LENGTH) {
-			bytesRead += getInputStream().read(reply.getBytes(), bytesRead,
-					Socks4Message.REPLY_LENGTH - bytesRead);
-		}
-		return reply;
-	}
+        Socks4Message reply = new Socks4Message();
+        int bytesRead = 0;
+        while (bytesRead < Socks4Message.REPLY_LENGTH) {
+            int count = getInputStream().read(reply.getBytes(), bytesRead,
+                    Socks4Message.REPLY_LENGTH - bytesRead);
+            if (-1 == count) {
+                break;
+            }
+            bytesRead += count;
+        }
+        if (Socks4Message.REPLY_LENGTH != bytesRead) {
+            throw new SocketException(Msg.getString("KA011"));
+        }
+        return reply;
+    }
 
 	/**
 	 * Connect the socket to the host/port specified by the SocketAddress with a

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties?rev=431544&r1=431543&r2=431544&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/ExternalMessages.properties
Tue Aug 15 00:04:42 2006
@@ -302,3 +302,5 @@
 KA00e=Radix {0} is less than Character.MIN_RADIX or greater than Character.MAX_RADIX
 KA00f=Socket output is shutdown
 KA010=Cannot read back reference to unshared object
+KA011=No such file or directory
+KA011=Malformed reply from SOCKS server



Mime
View raw message