summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@cyngn.com>2016-11-08 15:13:02 -0800
committerJessica Wagantall <jwagantall@cyngn.com>2016-11-09 11:59:03 -0800
commit1b7c3672b5219216119eb288d4363324a7f6667e (patch)
tree62a8b2809415de3d572b5fbcfb09407afdf1c53f
parent436c54bf01a5f9168a5e91d241bc28f2256cd08c (diff)
parenta1e0873bd8ab79f64296d1103a4e9e7ee6a5bbb7 (diff)
downloadlibcore-1b7c3672b5219216119eb288d4363324a7f6667e.zip
libcore-1b7c3672b5219216119eb288d4363324a7f6667e.tar.gz
libcore-1b7c3672b5219216119eb288d4363324a7f6667e.tar.bz2
Merge tag 'android-6.0.1_r74' into HEAD
CYNGNOS-3303 Android 6.0.1 release 74 Change-Id: I5d30d03599d97e81621add2516955ab40f1aeef7
-rw-r--r--luni/src/main/native/libcore_icu_NativeIDN.cpp9
-rw-r--r--luni/src/test/java/libcore/java/net/IDNTest.java11
2 files changed, 16 insertions, 4 deletions
diff --git a/luni/src/main/native/libcore_icu_NativeIDN.cpp b/luni/src/main/native/libcore_icu_NativeIDN.cpp
index 43f3ce5..9786b9d 100644
--- a/luni/src/main/native/libcore_icu_NativeIDN.cpp
+++ b/luni/src/main/native/libcore_icu_NativeIDN.cpp
@@ -37,7 +37,8 @@ static jstring NativeIDN_convertImpl(JNIEnv* env, jclass, jstring javaSrc, jint
if (src.get() == NULL) {
return NULL;
}
- UChar dst[256];
+ static const size_t kDstSize = 512;
+ UChar dst[kDstSize];
UErrorCode status = U_ZERO_ERROR;
// We're stuck implementing IDNA-2003 for now since that's what we specify.
@@ -47,10 +48,10 @@ static jstring NativeIDN_convertImpl(JNIEnv* env, jclass, jstring javaSrc, jint
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
size_t resultLength = toAscii
- ? uidna_IDNToASCII(src.get(), src.size(), &dst[0], sizeof(dst), flags, NULL, &status)
- : uidna_IDNToUnicode(src.get(), src.size(), &dst[0], sizeof(dst), flags, NULL, &status);
+ ? uidna_IDNToASCII(src.get(), src.size(), &dst[0], kDstSize, flags, NULL, &status)
+ : uidna_IDNToUnicode(src.get(), src.size(), &dst[0], kDstSize, flags, NULL, &status);
#pragma GCC diagnostic pop
-
+
if (U_FAILURE(status)) {
jniThrowException(env, "java/lang/IllegalArgumentException", u_errorName(status));
return NULL;
diff --git a/luni/src/test/java/libcore/java/net/IDNTest.java b/luni/src/test/java/libcore/java/net/IDNTest.java
index f01eca3..37f3505 100644
--- a/luni/src/test/java/libcore/java/net/IDNTest.java
+++ b/luni/src/test/java/libcore/java/net/IDNTest.java
@@ -37,4 +37,15 @@ public class IDNTest extends TestCase {
String longInput = makePunyString(512);
assertEquals(longInput, IDN.toUnicode(longInput));
}
+
+ // http://b/30765246
+ public void testLongDomainName() {
+ String label63 = "123456789-123456789-123456789-123456789-123456789-123456789-123";
+ String host255 = label63 + "." + label63 + "." + label63 + "." + label63;
+ try {
+ IDN.toASCII(host255.substring(3) + ".com");
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ }
}