You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/06/15 16:56:38 UTC

[tomcat] branch 8.5.x updated: Fix canonicalization of IPv6 addresses ending in "::"

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new debeb6c  Fix canonicalization of IPv6 addresses ending in "::"
debeb6c is described below

commit debeb6cc98ab617d7e4d17745fe43f278de904a0
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Jun 15 17:55:38 2020 +0100

    Fix canonicalization of IPv6 addresses ending in "::"
    
    Based on a patch by syarramsetty-skyhook
---
 java/org/apache/tomcat/util/net/IPv6Utils.java     | 2 +-
 test/org/apache/tomcat/util/net/TestIPv6Utils.java | 3 +++
 webapps/docs/changelog.xml                         | 5 +++++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/net/IPv6Utils.java b/java/org/apache/tomcat/util/net/IPv6Utils.java
index 94b8c49..bccc0a2 100644
--- a/java/org/apache/tomcat/util/net/IPv6Utils.java
+++ b/java/org/apache/tomcat/util/net/IPv6Utils.java
@@ -109,7 +109,7 @@ public class IPv6Utils {
         int length = ipv6AddressLength;
         int change = 0;
 
-        if (colonsPos >= 0 && colonsPos < ipv6AddressLength - 2) {
+        if (colonsPos >= 0 && colonsPos < ipv6AddressLength - 1) {
             int colonCounter = 0;
             for (int i = 0; i < ipv6AddressLength; i++) {
                 if (ipv6Address.charAt(i) == ':') {
diff --git a/test/org/apache/tomcat/util/net/TestIPv6Utils.java b/test/org/apache/tomcat/util/net/TestIPv6Utils.java
index a220dd7..5d667ed 100644
--- a/test/org/apache/tomcat/util/net/TestIPv6Utils.java
+++ b/test/org/apache/tomcat/util/net/TestIPv6Utils.java
@@ -111,6 +111,9 @@ public class TestIPv6Utils {
         Assert.assertEquals("2001:0:0:1::1", IPv6Utils.canonize("2001:0:0:1:0:0:0:1"));
         Assert.assertEquals("2001:db8::1:0:0:1", IPv6Utils.canonize("2001:db8:0:0:1:0:0:1"));
 
+        // Already ends with "::"
+        Assert.assertEquals("2001:db8::", IPv6Utils.canonize("2001:db8::"));
+
         // IPv4 inside IPv6
         Assert.assertEquals("::ffff:192.0.2.1", IPv6Utils.canonize("::ffff:192.0.2.1"));
         Assert.assertEquals("::ffff:192.0.2.1", IPv6Utils.canonize("0:0:0:0:0:ffff:192.0.2.1"));
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f5016f2..6ff20e5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -80,6 +80,11 @@
         comma as a separater between cookies when using the RFC 6265 cookie
         processor. Based on a patch by W J Carpenter. (markt)
       </fix>
+      <fix>
+        Fix the utility code that converted IPv6 addresses to a canonical form
+        to correctly handle input addresses that ended with a pair of colons.
+        Based on a patch by syarramsetty-skyhook. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Other">


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