Skip to content

Commit 7de8b25

Browse files
author
Jenkins
committed
Merge remote-tracking branch 'upstream/cm-12.1' into brn-12.1
2 parents 6b78e2c + 98abbaf commit 7de8b25

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

dalvik/src/main/java/dalvik/system/ZygoteHooks.java

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void preFork() {
3838
Daemons.stop();
3939
waitUntilAllThreadsStopped();
4040
token = nativePreFork();
41+
System.closeLogSockets();
4142
}
4243

4344
/**

luni/src/main/java/java/lang/System.java

+3
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,9 @@ public static void setSecurityManager(SecurityManager sm) {
11011101
}
11021102
}
11031103

1104+
/** @hide */
1105+
public static native void closeLogSockets();
1106+
11041107
/**
11051108
* Returns the platform specific file name format for the shared library
11061109
* named by the argument. On Android, this would turn {@code "MyLibrary"} into

luni/src/main/native/java_lang_System.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ static void System_log(JNIEnv* env, jclass, jchar type, jstring javaMessage, jth
6262
}
6363
}
6464

65+
static void System_closeLogSockets(JNIEnv*, jclass) {
66+
__android_log_close();
67+
}
68+
6569
// Sets a field via JNI. Used for the standard streams, which are read-only otherwise.
6670
static void System_setFieldImpl(JNIEnv* env, jclass clazz,
6771
jstring javaName, jstring javaSignature, jobject object) {
@@ -133,6 +137,7 @@ static jstring System_mapLibraryName(JNIEnv* env, jclass, jstring javaName) {
133137
}
134138

135139
static JNINativeMethod gMethods[] = {
140+
NATIVE_METHOD(System, closeLogSockets, "()V"),
136141
NATIVE_METHOD(System, currentTimeMillis, "!()J"),
137142
NATIVE_METHOD(System, log, "(CLjava/lang/String;Ljava/lang/Throwable;)V"),
138143
NATIVE_METHOD(System, mapLibraryName, "(Ljava/lang/String;)Ljava/lang/String;"),

luni/src/main/native/libcore_icu_NativeIDN.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ static jstring NativeIDN_convertImpl(JNIEnv* env, jclass, jstring javaSrc, jint
3737
if (src.get() == NULL) {
3838
return NULL;
3939
}
40-
UChar dst[256];
40+
static const size_t kDstSize = 512;
41+
UChar dst[kDstSize];
4142
UErrorCode status = U_ZERO_ERROR;
4243
size_t resultLength = toAscii
43-
? uidna_IDNToASCII(src.get(), src.size(), &dst[0], sizeof(dst), flags, NULL, &status)
44-
: uidna_IDNToUnicode(src.get(), src.size(), &dst[0], sizeof(dst), flags, NULL, &status);
44+
? uidna_IDNToASCII(src.get(), src.size(), &dst[0], kDstSize, flags, NULL, &status)
45+
: uidna_IDNToUnicode(src.get(), src.size(), &dst[0], kDstSize, flags, NULL, &status);
4546
if (U_FAILURE(status)) {
4647
jniThrowException(env, "java/lang/IllegalArgumentException", u_errorName(status));
4748
return NULL;

luni/src/test/java/libcore/java/net/IDNTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,15 @@ public void test_toUnicode_failures() {
3737
String longInput = makePunyString(512);
3838
assertEquals(longInput, IDN.toUnicode(longInput));
3939
}
40+
41+
// http://b/30765246
42+
public void testLongDomainName() {
43+
String label63 = "123456789-123456789-123456789-123456789-123456789-123456789-123";
44+
String host255 = label63 + "." + label63 + "." + label63 + "." + label63;
45+
try {
46+
IDN.toASCII(host255.substring(3) + ".com");
47+
fail();
48+
} catch (IllegalArgumentException expected) {
49+
}
50+
}
4051
}

0 commit comments

Comments
 (0)