From dd303ca9af64bda1a503d9918ec17a61e9b06e6d Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Wed, 23 Sep 2015 17:01:32 +0100 Subject: Patch for awaitNanos() for coarse-grained clocks If System.nanoTime() returns the same value twice in awaitNanos() then (remaining == initialNanos) will be true but the code will conclude that a (less likely) overflow occurred. Bug: 24284239 (cherry-picked from commit 8fc2ac0fa8eb47ce607f8412e469d4f680b6ef85) Change-Id: I3b9d573ea822e18f4c1849c8ab66071e66274a50 --- .../java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java | 5 ++++- .../java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'luni/src/main') diff --git a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java index 47a02a9..a74fb24 100644 --- a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java +++ b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java @@ -1838,7 +1838,10 @@ public abstract class AbstractQueuedLongSynchronizer if (interruptMode != 0) reportInterruptAfterWait(interruptMode); long remaining = deadline - System.nanoTime(); // avoid overflow - return (remaining < initialNanos) ? remaining : Long.MIN_VALUE; + // BEGIN android-note Changed from < to <= http://b/24284239 + // return (remaining < initialNanos) ? remaining : Long.MIN_VALUE; + return (remaining <= initialNanos) ? remaining : Long.MIN_VALUE; + // END android-note } /** diff --git a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java index bfe88e5..8823b6f 100644 --- a/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java +++ b/luni/src/main/java/java/util/concurrent/locks/AbstractQueuedSynchronizer.java @@ -2062,7 +2062,10 @@ public abstract class AbstractQueuedSynchronizer if (interruptMode != 0) reportInterruptAfterWait(interruptMode); long remaining = deadline - System.nanoTime(); // avoid overflow - return (remaining < initialNanos) ? remaining : Long.MIN_VALUE; + // BEGIN android-note Changed from < to <= http://b/24284239 + // return (remaining < initialNanos) ? remaining : Long.MIN_VALUE; + return (remaining <= initialNanos) ? remaining : Long.MIN_VALUE; + // END android-note } /** -- cgit v1.1 From a1e0873bd8ab79f64296d1103a4e9e7ee6a5bbb7 Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Fri, 19 Aug 2016 15:26:24 +0100 Subject: 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 --- luni/src/main/native/libcore_icu_NativeIDN.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'luni/src/main') 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; -- cgit v1.1