diff options
author | Alex Klyubin <klyubin@google.com> | 2014-11-18 17:45:01 -0800 |
---|---|---|
committer | Brint E. Kriebel <bekit@cyngn.com> | 2015-03-18 13:54:11 -0700 |
commit | 24aad7677073f7c2116b105e53ba2eaa05917209 (patch) | |
tree | b27018a5dfaad1efdeecbd9be0d437fa41321ade | |
parent | 3479d99860aa4ac9eeac508f524958933d5e4472 (diff) | |
download | android_external_okhttp-cm-12.0.tar.gz android_external_okhttp-cm-12.0.tar.bz2 android_external_okhttp-cm-12.0.zip |
Fix a bug in OkHostnameVerifier wildcard handling.stable/cm-12.0-YNG4Nstable/cm-12.0-YNG3Ccm-12.0
Wildcard domain name patterns of the form *.remainder are supposed to
match domain names that exactly match the remainder. Due to a bug,
the match was not exact but rather a prefix match: domain names
starting with the remainder would match too.
This CL fixes the issue.
Bug: 18432707
Change-Id: I2639ff51cabcbd395d4f30a9c69f9895738e0acf
-rw-r--r-- | okhttp-tests/src/test/java/com/squareup/okhttp/internal/tls/HostnameVerifierTest.java | 1 | ||||
-rw-r--r-- | okhttp/src/main/java/com/squareup/okhttp/internal/tls/OkHostnameVerifier.java | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/okhttp-tests/src/test/java/com/squareup/okhttp/internal/tls/HostnameVerifierTest.java b/okhttp-tests/src/test/java/com/squareup/okhttp/internal/tls/HostnameVerifierTest.java index f1decc8..82b1952 100644 --- a/okhttp-tests/src/test/java/com/squareup/okhttp/internal/tls/HostnameVerifierTest.java +++ b/okhttp-tests/src/test/java/com/squareup/okhttp/internal/tls/HostnameVerifierTest.java @@ -293,6 +293,7 @@ public final class HostnameVerifierTest { assertTrue(verifier.verify("www.foo.com", session)); assertTrue(verifier.verify("\u82b1\u5b50.foo.com", session)); assertFalse(verifier.verify("a.b.foo.com", session)); + assertFalse(verifier.verify("foo.com.au", session)); } @Test public void verifyWilcardCnOnTld() throws Exception { diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/tls/OkHostnameVerifier.java b/okhttp/src/main/java/com/squareup/okhttp/internal/tls/OkHostnameVerifier.java index a08773f..21e539c 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/tls/OkHostnameVerifier.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/tls/OkHostnameVerifier.java @@ -162,7 +162,7 @@ public final class OkHostnameVerifier implements HostnameVerifier { return hostName.equals(cn); } - if (cn.startsWith("*.") && hostName.regionMatches(0, cn, 2, cn.length() - 2)) { + if (cn.startsWith("*.") && hostName.equals(cn.substring(2))) { return true; // "*.foo.com" matches "foo.com" } |