From: markt Date: Sun, 5 Jun 2011 20:26:37 +0000 (+0000) Subject: Parse port as base10, not hex X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0a37ae36f1eb7912b44d612c2e8adfc134c1088a;p=tomcat7.0 Parse port as base10, not hex git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1132487 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/coyote/http11/AbstractHttp11Processor.java b/java/org/apache/coyote/http11/AbstractHttp11Processor.java index cc02488d8..fb2352941 100644 --- a/java/org/apache/coyote/http11/AbstractHttp11Processor.java +++ b/java/org/apache/coyote/http11/AbstractHttp11Processor.java @@ -39,7 +39,6 @@ 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,26 +992,9 @@ public abstract class AbstractHttp11Processor extends AbstractProcessor { } request.serverName().setChars(hostNameC, 0, valueL); } else { - request.serverName().setChars(hostNameC, 0, colonPos); - - int port = 0; - int mult = 1; - for (int i = valueL - 1; i > colonPos; i--) { - int charValue = HexUtils.getDec(valueB[i + valueS]); - if (charValue == -1) { - // 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); - + request.setServerPort(Ascii.parseInt( + valueB, valueS + colonPos + 1, valueL - colonPos - 1)); } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 35ad9e789..bb6a4a322 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -49,6 +49,10 @@ Correctly handle range requests when using sendfile and the APR/native HTTP connector. (markt) + + When parsing the port in the HTTP host header, treat the port as a base + 10 integer rather than a hexadecimal one. (rjung/markt) +