diff options
author | Narayan Kamath <narayan@google.com> | 2016-08-19 15:26:24 +0100 |
---|---|---|
committer | Adam Seaton <aseaton@google.com> | 2016-09-27 13:31:03 -0700 |
commit | a1e0873bd8ab79f64296d1103a4e9e7ee6a5bbb7 (patch) | |
tree | c07d7b05a78f1ed30aeec172a8dd41ae1bc3a682 /luni/src/main/native/libcore_icu_NativeIDN.cpp | |
parent | c95c72ec796254f98e12d108d6f6d0e06d01bcd3 (diff) | |
download | libcore-a1e0873bd8ab79f64296d1103a4e9e7ee6a5bbb7.zip libcore-a1e0873bd8ab79f64296d1103a4e9e7ee6a5bbb7.tar.gz libcore-a1e0873bd8ab79f64296d1103a4e9e7ee6a5bbb7.tar.bz2 |
IDN: Fix handling of long domain names.
Fix merge conflict into mnc-mr2-release
We were incorrectly using sizeof() to calculate the size of the
output array. Note that this change also changes the output size
to 512 to minimize behavioural differences (especially wrt. ICU
checks on sizes).
bug: 30765246
Change-Id: I5d28ddc45d2d6d2bed3e479ca195ed2779b906ed
Diffstat (limited to 'luni/src/main/native/libcore_icu_NativeIDN.cpp')
-rw-r--r-- | luni/src/main/native/libcore_icu_NativeIDN.cpp | 9 |
1 files changed, 5 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; |