tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1132700 - in /tomcat/trunk: java/org/apache/coyote/http11/AbstractHttp11Processor.java webapps/docs/changelog.xml
Date Mon, 06 Jun 2011 16:53:37 GMT
Author: markt
Date: Mon Jun  6 16:53:37 2011
New Revision: 1132700

URL: http://svn.apache.org/viewvc?rev=1132700&view=rev
Log:
Revert r1132487 and use Konstantin's suggested fix.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1132700&r1=1132699&r2=1132700&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Mon Jun  6 16:53:37
2011
@@ -39,6 +39,7 @@ import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.buf.Ascii;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.HexUtils;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
 import org.apache.tomcat.util.http.MimeHeaders;
@@ -993,8 +994,23 @@ public abstract class AbstractHttp11Proc
             request.serverName().setChars(hostNameC, 0, valueL);
         } else {
             request.serverName().setChars(hostNameC, 0, colonPos);
-            request.setServerPort(Ascii.parseInt(
-                    valueB, valueS + colonPos + 1, valueL - colonPos - 1));
+            
+            int port = 0;
+            int mult = 1;
+            for (int i = valueL - 1; i > colonPos; i--) {
+                int charValue = HexUtils.getDec(valueB[i + valueS]);
+                if (charValue == -1 || charValue > 9) {
+                    // Invalid character
+                    error = true;
+                    // 400 - Bad request
+                    response.setStatus(400);
+                    adapter.log(request, response, 0);
+                    break;
+                }
+                port = port + (charValue * mult);
+                mult = 10 * mult;
+            }
+            request.setServerPort(port);
         }
 
     }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1132700&r1=1132699&r2=1132700&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Jun  6 16:53:37 2011
@@ -51,7 +51,7 @@
       </fix>
       <fix>
         When parsing the port in the HTTP host header, treat the port as a base
-        10 integer rather than a hexadecimal one. (rjung/markt) 
+        10 integer rather than a hexadecimal one. (rjung/markt/kkolinko) 
       </fix>
     </changelog>
   </subsection>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message