From 579e48fd608c6ffc2ed7a9b6c65061320bc7bc55 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Fri, 19 Sep 2014 16:34:59 +0200 Subject: [PATCH 1/7] 8055032: Improve numerical parsing in java.net and sun.net Reviewed-by: alanb --- jdk/src/java.base/share/classes/java/net/CookieManager.java | 2 +- jdk/src/java.base/share/classes/java/net/URI.java | 4 ++-- jdk/src/java.base/share/classes/java/net/URLDecoder.java | 2 +- .../java.base/share/classes/java/net/URLStreamHandler.java | 6 ++++-- .../share/classes/sun/net/TransferProtocolClient.java | 2 +- .../java.base/share/classes/sun/net/ftp/impl/FtpClient.java | 6 +++--- jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java | 2 +- .../share/classes/sun/net/www/http/ChunkedInputStream.java | 2 +- .../share/classes/sun/net/www/http/HttpClient.java | 2 +- jdk/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java | 3 ++- 10 files changed, 17 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/net/CookieManager.java b/jdk/src/java.base/share/classes/java/net/CookieManager.java index 15d4cc33e08..4dbc9aa2dfa 100644 --- a/jdk/src/java.base/share/classes/java/net/CookieManager.java +++ b/jdk/src/java.base/share/classes/java/net/CookieManager.java @@ -368,7 +368,7 @@ public class CookieManager extends CookieHandler int val = -1; while (i > 0) { try { - val = Integer.parseInt(lst.substring(0, i)); + val = Integer.parseInt(lst, 0, i, 10); if (val == port) { return true; } diff --git a/jdk/src/java.base/share/classes/java/net/URI.java b/jdk/src/java.base/share/classes/java/net/URI.java index 62dea657c04..c656ac71c11 100644 --- a/jdk/src/java.base/share/classes/java/net/URI.java +++ b/jdk/src/java.base/share/classes/java/net/URI.java @@ -3250,7 +3250,7 @@ public final class URI if (q > p) { checkChars(p, q, L_DIGIT, H_DIGIT, "port number"); try { - port = Integer.parseInt(substring(p, q)); + port = Integer.parseInt(input, p, q, 10); } catch (NumberFormatException x) { fail("Malformed port number", p); } @@ -3271,7 +3271,7 @@ public final class URI int p = start; int q = scan(p, n, L_DIGIT, H_DIGIT); if (q <= p) return q; - if (Integer.parseInt(substring(p, q)) > 255) return p; + if (Integer.parseInt(input, p, q, 10) > 255) return p; return q; } diff --git a/jdk/src/java.base/share/classes/java/net/URLDecoder.java b/jdk/src/java.base/share/classes/java/net/URLDecoder.java index 2c65c95fefc..9aa5ddc2039 100644 --- a/jdk/src/java.base/share/classes/java/net/URLDecoder.java +++ b/jdk/src/java.base/share/classes/java/net/URLDecoder.java @@ -171,7 +171,7 @@ public class URLDecoder { while ( ((i+2) < numChars) && (c=='%')) { - int v = Integer.parseInt(s.substring(i+1,i+3),16); + int v = Integer.parseInt(s, i + 1, i + 3, 16); if (v < 0) throw new IllegalArgumentException("URLDecoder: Illegal hex characters in escape (%) pattern - negative value"); bytes[pos++] = (byte) v; diff --git a/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java b/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java index 9ea65260f3d..56506ba33bb 100644 --- a/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java +++ b/jdk/src/java.base/share/classes/java/net/URLStreamHandler.java @@ -196,7 +196,8 @@ public abstract class URLStreamHandler { ++ind ; // port can be null according to RFC2396 if (nhost.length() > (ind + 1)) { - port = Integer.parseInt(nhost.substring(ind+1)); + port = Integer.parseInt(nhost, ind + 1, + nhost.length(), 10); } } else { throw new IllegalArgumentException( @@ -213,7 +214,8 @@ public abstract class URLStreamHandler { if (ind >= 0) { // port can be null according to RFC2396 if (host.length() > (ind + 1)) { - port = Integer.parseInt(host.substring(ind + 1)); + port = Integer.parseInt(host, ind + 1, + host.length(), 10); } host = host.substring(0, ind); } diff --git a/jdk/src/java.base/share/classes/sun/net/TransferProtocolClient.java b/jdk/src/java.base/share/classes/sun/net/TransferProtocolClient.java index 2c3ae2e1f6e..b3a9fd556e6 100644 --- a/jdk/src/java.base/share/classes/sun/net/TransferProtocolClient.java +++ b/jdk/src/java.base/share/classes/sun/net/TransferProtocolClient.java @@ -80,7 +80,7 @@ public class TransferProtocolClient extends NetworkClient { code = -1; } else { try { - code = Integer.parseInt(response.substring(0, 3)); + code = Integer.parseInt(response, 0, 3, 10); } catch (NumberFormatException e) { code = -1; } catch (StringIndexOutOfBoundsException e) { diff --git a/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java b/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java index 5f8c8586072..61ab2fbb9d3 100644 --- a/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java +++ b/jdk/src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java @@ -260,8 +260,8 @@ public class FtpClient extends sun.net.ftp.FtpClient { if (d != null && time != null) { int c = time.indexOf(':'); now.setTime(d); - now.set(Calendar.HOUR, Integer.parseInt(time.substring(0, c))); - now.set(Calendar.MINUTE, Integer.parseInt(time.substring(c + 1))); + now.set(Calendar.HOUR, Integer.parseInt(time, 0, c, 10)); + now.set(Calendar.MINUTE, Integer.parseInt(time, c + 1, time.length(), 10)); d = now.getTime(); } // see if it's a symbolic link, i.e. the name if followed @@ -437,7 +437,7 @@ public class FtpClient extends sun.net.ftp.FtpClient { code = -1; } else { try { - code = Integer.parseInt(response.substring(0, 3)); + code = Integer.parseInt(response, 0, 3, 10); } catch (NumberFormatException e) { code = -1; } catch (StringIndexOutOfBoundsException e) { diff --git a/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java b/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java index cb8311996b1..1c9abf9d1f4 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java +++ b/jdk/src/java.base/share/classes/sun/net/www/ParseUtil.java @@ -161,7 +161,7 @@ public class ParseUtil { * Un-escape and return the character at position i in string s. */ private static byte unescape(String s, int i) { - return (byte) Integer.parseInt(s.substring(i+1,i+3),16); + return (byte) Integer.parseInt(s, i + 1, i + 3, 16); } diff --git a/jdk/src/java.base/share/classes/sun/net/www/http/ChunkedInputStream.java b/jdk/src/java.base/share/classes/sun/net/www/http/ChunkedInputStream.java index 222ddc0ba1c..3f36aa11653 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/http/ChunkedInputStream.java +++ b/jdk/src/java.base/share/classes/sun/net/www/http/ChunkedInputStream.java @@ -313,7 +313,7 @@ class ChunkedInputStream extends InputStream implements Hurryable { break; } try { - chunkSize = Integer.parseInt(header.substring(0, i), 16); + chunkSize = Integer.parseInt(header, 0, i, 16); } catch (NumberFormatException e) { error = true; throw new IOException("Bogus chunk size"); diff --git a/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java b/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java index e899ac9b607..0e07d3ab65c 100644 --- a/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java +++ b/jdk/src/java.base/share/classes/sun/net/www/http/HttpClient.java @@ -808,7 +808,7 @@ public class HttpClient extends NetworkClient { ind = resp.indexOf(' '); while(resp.charAt(ind) == ' ') ind++; - code = Integer.parseInt(resp.substring(ind, ind + 3)); + code = Integer.parseInt(resp, ind, ind + 3, 10); } catch (Exception e) {} if (code == HTTP_CONTINUE && ignoreContinue) { diff --git a/jdk/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java b/jdk/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java index 74bcfeae34e..ec974744419 100644 --- a/jdk/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java +++ b/jdk/src/java.base/unix/classes/sun/net/sdp/SdpProvider.java @@ -257,7 +257,8 @@ public class SdpProvider extends NetHooks.Provider { .getByName(s[1].substring(0, pos)); int prefix = -1; try { - prefix = Integer.parseInt(s[1].substring(pos+1)); + prefix = Integer.parseInt(s[1], pos + 1, + s[1].length(), 10); if (address instanceof Inet4Address) { // must be 1-31 if (prefix < 0 || prefix > 32) prefix = -1; From 8a75d987d3919a0915d150385d115f2553ea6d7e Mon Sep 17 00:00:00 2001 From: Sergey Gabdurakhmanov Date: Mon, 22 Sep 2014 10:47:27 +0200 Subject: [PATCH 2/7] 8057564: JVM hangs at getAgentProperties after attaching to VM with lower Create custom Security Descriptor for Named Pipe. Reviewed-by: mgronlun, dsamersoff, uta --- .../native/libattach/VirtualMachineImpl.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/jdk/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c b/jdk/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c index 2fc0438f82a..f92101f8924 100644 --- a/jdk/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c +++ b/jdk/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c @@ -23,6 +23,7 @@ * questions. */ #include +#include #include #include "jni.h" @@ -258,6 +259,25 @@ JNIEXPORT jlong JNICALL Java_sun_tools_attach_VirtualMachineImpl_createPipe HANDLE hPipe; char name[MAX_PIPE_NAME_LENGTH]; + SECURITY_ATTRIBUTES sa; + LPSECURITY_ATTRIBUTES lpSA = NULL; + // Custom Security Descriptor is required here to "get" Medium Integrity Level. + // In order to allow Medium Integrity Level clients to open + // and use a NamedPipe created by an High Integrity Level process. + TCHAR *szSD = TEXT("D:") // Discretionary ACL + TEXT("(A;OICI;GRGW;;;WD)") // Allow read/write to Everybody + TEXT("(A;OICI;GA;;;SY)") // Allow full control to System + TEXT("(A;OICI;GA;;;BA)"); // Allow full control to Administrators + + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + sa.bInheritHandle = FALSE; + sa.lpSecurityDescriptor = NULL; + + if (ConvertStringSecurityDescriptorToSecurityDescriptor + (szSD, SDDL_REVISION_1, &(sa.lpSecurityDescriptor), NULL)) { + lpSA = &sa; + } + jstring_to_cstring(env, pipename, name, MAX_PIPE_NAME_LENGTH); hPipe = CreateNamedPipe( @@ -270,7 +290,9 @@ JNIEXPORT jlong JNICALL Java_sun_tools_attach_VirtualMachineImpl_createPipe 128, // output buffer size 8192, // input buffer size NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + lpSA); // security attributes + + LocalFree(sa.lpSecurityDescriptor); if (hPipe == INVALID_HANDLE_VALUE) { char msg[256]; From 24028df23720a3e618c300afe846da6ff99d94be Mon Sep 17 00:00:00 2001 From: Sandipan Razzaque Date: Mon, 22 Sep 2014 10:41:45 -0700 Subject: [PATCH 3/7] 8043740: Doubles with large exponents overflow to Infinity incorrectly Modify test of exponent overflow to account for subsequent decrement. Reviewed-by: darcy --- .../classes/sun/misc/FloatingDecimal.java | 41 ++++++++++++------- jdk/test/java/lang/Double/ParseDouble.java | 15 +++++++ 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/misc/FloatingDecimal.java b/jdk/src/java.base/share/classes/sun/misc/FloatingDecimal.java index ddd8790bc14..eef4caf9905 100644 --- a/jdk/src/java.base/share/classes/sun/misc/FloatingDecimal.java +++ b/jdk/src/java.base/share/classes/sun/misc/FloatingDecimal.java @@ -1992,21 +1992,32 @@ public class FloatingDecimal{ break expLoop; // stop parsing exponent. } } - int expLimit = BIG_DECIMAL_EXPONENT+nDigits+nTrailZero; - if ( expOverflow || ( expVal > expLimit ) ){ - // - // The intent here is to end up with - // infinity or zero, as appropriate. - // The reason for yielding such a small decExponent, - // rather than something intuitive such as - // expSign*Integer.MAX_VALUE, is that this value - // is subject to further manipulation in - // doubleValue() and floatValue(), and I don't want - // it to be able to cause overflow there! - // (The only way we can get into trouble here is for - // really outrageous nDigits+nTrailZero, such as 2 billion. ) - // - decExp = expSign*expLimit; + int expLimit = BIG_DECIMAL_EXPONENT + nDigits + nTrailZero; + if (expOverflow || (expVal > expLimit)) { + // There is still a chance that the exponent will be safe to + // use: if it would eventually decrease due to a negative + // decExp, and that number is below the limit. We check for + // that here. + if (!expOverflow && (expSign == 1 && decExp < 0) + && (expVal + decExp) < expLimit) { + // Cannot overflow: adding a positive and negative number. + decExp += expVal; + } else { + // + // The intent here is to end up with + // infinity or zero, as appropriate. + // The reason for yielding such a small decExponent, + // rather than something intuitive such as + // expSign*Integer.MAX_VALUE, is that this value + // is subject to further manipulation in + // doubleValue() and floatValue(), and I don't want + // it to be able to cause overflow there! + // (The only way we can get into trouble here is for + // really outrageous nDigits+nTrailZero, such as 2 + // billion.) + // + decExp = expSign * expLimit; + } } else { // this should not overflow, since we tested // for expVal > (MAX+N), where N >= abs(decExp) diff --git a/jdk/test/java/lang/Double/ParseDouble.java b/jdk/test/java/lang/Double/ParseDouble.java index 381ddf1922c..ff4a3b80af3 100644 --- a/jdk/test/java/lang/Double/ParseDouble.java +++ b/jdk/test/java/lang/Double/ParseDouble.java @@ -512,6 +512,21 @@ public class ParseDouble { "2.2250738585072014e-308", // Double.MIN_NORMAL "2.2250738585072012e-308", // near Double.MIN_NORMAL + + "1.7976931348623158e+308", // near MAX_VALUE + ulp(MAX_VALUE)/2 + "1.7976931348623159e+308", // near MAX_VALUE + ulp(MAX_VALUE) + + "2.4703282292062329e-324", // above MIN_VALUE/2 + "2.4703282292062327e-324", // MIN_VALUE/2 + "2.4703282292062325e-324", // below MIN_VALUE/2 + + // 1e308 with leading zeros + + "0.0000000000001e321", + "00.000000000000000001e326", + "00000.000000000000000001e326", + "000.0000000000000000001e327", + "0.00000000000000000001e328", }; static String paddedBadStrings[]; From 7d629c8335b613e6e6deffe30265eafd526f7a04 Mon Sep 17 00:00:00 2001 From: Mikael Auno Date: Thu, 18 Sep 2014 11:34:14 +0200 Subject: [PATCH 4/7] 8058647: sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java should be quarantined Reviewed-by: jbachorik --- jdk/test/ProblemList.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 7aed17601cd..44dc7102452 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -298,4 +298,7 @@ sun/tools/jstatd/TestJstatdExternalRegistry.java generic-all # 6456333 sun/tools/jps/TestJpsJarRelative.java generic-all +# 8057732 +sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java generic-all + ############################################################################ From ebe3ab9dd234fc1aa404b9973110cfef500ce4a4 Mon Sep 17 00:00:00 2001 From: Mikael Auno Date: Thu, 18 Sep 2014 11:34:14 +0200 Subject: [PATCH 5/7] 8058649: java/lang/management/ThreadMXBean/FindDeadlocks.java should be quarantined Reviewed-by: jbachorik --- jdk/test/ProblemList.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 44dc7102452..73135636503 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -130,6 +130,9 @@ com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java # 8056143 java/lang/management/MemoryMXBean/LowMemoryTest.java generic-all +# 8058492 +java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all + ############################################################################ # jdk_jmx From f2677eae506b56b034476a69d98c3e5430d6ea2e Mon Sep 17 00:00:00 2001 From: Mikael Auno Date: Thu, 18 Sep 2014 11:34:14 +0200 Subject: [PATCH 6/7] 8058651: com/sun/jdi/RedefinePop.sh should be quarantined Reviewed-by: jbachorik --- jdk/test/ProblemList.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 73135636503..3137ff0ac95 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -271,6 +271,9 @@ com/sun/jdi/RepStep.java generic-all # 8044419 com/sun/jdi/JdbReadTwiceTest.sh generic-all +# 8058616 +com/sun/jdi/RedefinePop.sh generic-all + ############################################################################ # jdk_util From 42e13628a3772cb293cc8e575fc881d76c5898a0 Mon Sep 17 00:00:00 2001 From: Mikael Auno Date: Thu, 18 Sep 2014 11:34:14 +0200 Subject: [PATCH 7/7] 8058652: java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java should be quarantined Reviewed-by: jbachorik --- jdk/test/ProblemList.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 3137ff0ac95..b664710bf43 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -133,6 +133,9 @@ java/lang/management/MemoryMXBean/LowMemoryTest.java # 8058492 java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all +# 8058506 +java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java generic-all + ############################################################################ # jdk_jmx