提交 5369f5f2 编写于 作者: M mfang

Merge

......@@ -417,3 +417,4 @@ bdcb84f205482c7aea48a1403e843f5fd689d849 jdk8u60-b11
a006fa0a9e8f18dee6daf8984bd11625c4c4860c jdk8u60-b15
6ed3821c212a93ffc6bfcc292ef7aca3b7165139 jdk8u60-b16
c30db4c968f63dce1bf2f9df240fb75a8f27f922 jdk8u60-b17
57336c319de8a141d0bcd04265ce36734fb51380 jdk8u60-b18
......@@ -377,7 +377,6 @@ public class HKSCS {
dst[dp++] = repl[1];
continue;
}
sp++;
}
if (bb > MAX_SINGLEBYTE) { // DoubleByte
dst[dp++] = (byte)(bb >> 8);
......
......@@ -144,7 +144,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray ret = 0;
int retLen = 0;
int error=0;
int getaddrinfo_error=0;
struct addrinfo hints, *res, *resNew = NULL;
if (!initializeInetClasses(env))
......@@ -172,22 +172,23 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
return NULL;
}
getaddrinfo_error = getaddrinfo(hostname, NULL, &hints, &res);
#ifdef MACOSX
/* If we're looking up the local machine, bypass DNS lookups and get
* address from getifaddrs.
*/
ret = lookupIfLocalhost(env, hostname, JNI_FALSE);
if (ret != NULL || (*env)->ExceptionCheck(env)) {
JNU_ReleaseStringPlatformChars(env, host, hostname);
return ret;
if (getaddrinfo_error) {
// If getaddrinfo fails try getifaddrs.
ret = lookupIfLocalhost(env, hostname, JNI_FALSE);
if (ret != NULL || (*env)->ExceptionCheck(env)) {
JNU_ReleaseStringPlatformChars(env, host, hostname);
return ret;
}
}
#endif
error = getaddrinfo(hostname, NULL, &hints, &res);
if (error) {
if (getaddrinfo_error) {
/* report error */
ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
ThrowUnknownHostExceptionWithGaiError(
env, hostname, getaddrinfo_error);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
......
......@@ -296,7 +296,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray ret = 0;
int retLen = 0;
int error=0;
int getaddrinfo_error=0;
#ifdef AF_INET6
struct addrinfo hints, *res, *resNew = NULL;
#endif /* AF_INET6 */
......@@ -311,19 +311,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL);
#ifdef MACOSX
/*
* If we're looking up the local machine, attempt to get the address
* from getifaddrs. This ensures we get an IPv6 address for the local
* machine.
*/
ret = lookupIfLocalhost(env, hostname, JNI_TRUE);
if (ret != NULL || (*env)->ExceptionCheck(env)) {
JNU_ReleaseStringPlatformChars(env, host, hostname);
return ret;
}
#endif
#ifdef AF_INET6
/* Try once, with our static buffer. */
memset(&hints, 0, sizeof(hints));
......@@ -343,11 +330,27 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
}
#endif
error = getaddrinfo(hostname, NULL, &hints, &res);
getaddrinfo_error = getaddrinfo(hostname, NULL, &hints, &res);
#ifdef MACOSX
if (getaddrinfo_error) {
/*
* If getaddrinfo fails looking up the local machine, attempt to get the
* address from getifaddrs. This ensures we get an IPv6 address for the
* local machine.
*/
ret = lookupIfLocalhost(env, hostname, JNI_TRUE);
if (ret != NULL || (*env)->ExceptionCheck(env)) {
JNU_ReleaseStringPlatformChars(env, host, hostname);
return ret;
}
}
#endif
if (error) {
if (getaddrinfo_error) {
/* report error */
ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
ThrowUnknownHostExceptionWithGaiError(
env, hostname, getaddrinfo_error);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
......
/*
* Copyright 2014 Google, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package parse.jdk7156085;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.DefaultHandler;
import org.testng.annotations.Test;
/**
* JDK-7156085: ArrayIndexOutOfBoundsException throws in UTF8Reader of SAXParser
* https://bugs.openjdk.java.net/browse/JDK-7156085
*
* XERCESJ-1257: buffer overflow in UTF8Reader for characters out of BMP
* https://issues.apache.org/jira/browse/XERCESJ-1257
*/
public class UTF8ReaderBug {
@Test
public void shouldAcceptSupplementaryCharacters() throws Throwable {
StringBuilder b = new StringBuilder("<xml>");
for(int i = 5; i < 8223; i++) {
b.append(' ');
}
// Add surrogate characters which overflow the buffer. This shows the need to place an
// overflow check at --
// com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:544)
b.append("\uD835\uDC37");
b.append("</xml>");
sendToParser(b.toString());
}
private static void sendToParser(String b) throws Throwable {
byte[] input = b.getBytes("UTF-8");
ByteArrayInputStream in = new ByteArrayInputStream(input);
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser p = spf.newSAXParser();
p.parse(new InputSource(in), new DefaultHandler());
}
}
......@@ -22,7 +22,7 @@
*/
/* @test
@bug 6636323 6636319 7040220 7096080 7183053
@bug 6636323 6636319 7040220 7096080 7183053 8080248
@summary Test if StringCoding and NIO result have the same de/encoding result
* @run main/othervm/timeout=2000 TestStringCoding
*/
......@@ -199,6 +199,17 @@ public class TestStringCoding {
*/
}
//encode mappable surrogates for hkscs
if (cs.name().equals("Big5-HKSCS") || cs.name().equals("x-MS950-HKSCS")) {
String str = "ab\uD840\uDD0Ccd";
byte[] expected = new byte[] {(byte)'a', (byte)'b',
(byte)0x88, (byte)0x45, (byte)'c', (byte)'d' };
if (!Arrays.equals(str.getBytes(cs.name()), expected) ||
!Arrays.equals(str.getBytes(cs), expected)) {
throw new RuntimeException("encode(surrogates) failed -> "
+ cs.name());
}
}
}
static class PermissiveSecurityManger extends SecurityManager {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册