This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: FYI: fix PR 27231


I'm checking this in to classpath and the gcj 4.1 branch.

This fixes PR 27231.  We weren't properly handling the case where no
'/' appeared in the redirect location.

It would be nice if FindBugs could catch the case where the result of
indexOf is directly passed to substring (maybe it does already?  I
didn't check).

Tom

2006-04-21  Tom Tromey  <tromey@redhat.com>

	PR libgcj/27231:
	* gnu/java/net/protocol/http/HTTPURLConnection.java (connect): Handle
	case where no '/' appears in 'location'.

Index: gnu/java/net/protocol/http/HTTPURLConnection.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/net/protocol/http/HTTPURLConnection.java,v
retrieving revision 1.24
diff -u -r1.24 HTTPURLConnection.java
--- gnu/java/net/protocol/http/HTTPURLConnection.java	6 Mar 2006 19:08:30 -0000	1.24
+++ gnu/java/net/protocol/http/HTTPURLConnection.java	21 Apr 2006 17:25:40 -0000
@@ -267,6 +267,8 @@
 		    secure = false;
 		    start = 7;
 		    int end = location.indexOf('/', start);
+                    if (end == -1)
+                      end = location.length();
 		    host = location.substring(start, end);
 		    int ci = host.lastIndexOf(':');
 		    if (ci != -1)
@@ -288,6 +290,8 @@
 		    secure = true;
 		    start = 8;
 		    int end = location.indexOf('/', start);
+                    if (end == -1)
+                      end = location.length();
 		    host = location.substring(start, end);
 		    int ci = host.lastIndexOf(':');
 		    if (ci != -1)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]