Merge tag 'android-security-10.0.0_r53' into int/10/fp2
Android security 10.0.0 release 53
* tag 'android-security-10.0.0_r53':
[DO NOT MERGE] Reject non-ASCII hostnames and SANs.
Change-Id: Idf3447f1f774e714fa2ecd731a8cbeb39ccfb085
diff --git a/expectations/knownfailures.txt b/expectations/knownfailures.txt
index 5dd1d1e..6c14660 100644
--- a/expectations/knownfailures.txt
+++ b/expectations/knownfailures.txt
@@ -1426,6 +1426,13 @@
]
},
{
+ description: "OkHttp flaky test of functionality that's not used on Android",
+ bug: 138134183,
+ names: [
+ "com.squareup.okhttp.internal.framed.Spdy3ConnectionTest#serverSendsSettingsToClient"
+ ]
+},
+{
description: "libcore.java.text.DecimalFormatSymbolsTest#test_getInstance_unknown_or_invalid_locale assumes fallback to locale other than en_US_POSIX.",
bug: 17422813,
names: [
diff --git a/luni/src/test/java/libcore/java/net/OldSocketTest.java b/luni/src/test/java/libcore/java/net/OldSocketTest.java
index 8a577fb..644fe52 100644
--- a/luni/src/test/java/libcore/java/net/OldSocketTest.java
+++ b/luni/src/test/java/libcore/java/net/OldSocketTest.java
@@ -20,6 +20,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.net.BindException;
import java.net.ConnectException;
import java.net.Inet4Address;
@@ -37,6 +39,7 @@
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.SocketChannel;
import java.security.Permission;
+import java.util.concurrent.atomic.AtomicReference;
import libcore.junit.util.ResourceLeakageDetector.DisableResourceLeakageDetection;
import tests.support.Support_Configuration;
@@ -1266,39 +1269,37 @@
}
}
- @DisableResourceLeakageDetection(
- why = "Strange threading behavior causes resource leak",
- bug = "31820278")
public void test_connectLjava_net_SocketAddressI_setSOTimeout() throws Exception {
+ final AtomicReference<Exception> exceptionRef = new AtomicReference<>();
+
class SocketConnector extends Thread {
+ private final int timeout;
+ private final Socket theSocket;
+ private final SocketAddress address;
- int timeout = 0;
-
- Socket theSocket = null;
-
- SocketAddress address = null;
-
+ @Override
public void run() {
try {
theSocket.connect(address, timeout);
} catch (Exception e) {
+ exceptionRef.set(e);
}
-
- return;
}
- public SocketConnector(int timeout, Socket theSocket,
- SocketAddress address) {
+ private SocketConnector(int timeout, Socket theSocket, SocketAddress address) {
this.timeout = timeout;
this.theSocket = theSocket;
this.address = address;
}
}
- // now try to set options while we are connecting
- SocketAddress nonReachableAddress = UNREACHABLE_ADDRESS;
- try (Socket theSocket = new Socket()) {
- SocketConnector connector = new SocketConnector(5000, theSocket, nonReachableAddress);
+ // Now try to set options while we are connecting
+ try (final Socket theSocket = new Socket()) {
+ // Force SocketImpl creation to prevent race between connect() and setSoTimeout()
+ // creating it. b/144258500
+ theSocket.getSoTimeout();
+ final SocketConnector connector
+ = new SocketConnector(5000, theSocket, UNREACHABLE_ADDRESS);
connector.start();
theSocket.setSoTimeout(1000);
Thread.sleep(10);
@@ -1308,10 +1309,21 @@
theSocket.setSoTimeout(2000);
assertTrue("Socket option not set during connect: 50 ",
Math.abs(2000 - theSocket.getSoTimeout()) <= 10);
- Thread.sleep(5000);
+ connector.join();
+ Exception e = exceptionRef.get();
+ if (!(e instanceof SocketTimeoutException)) {
+ fail(printStackTraceToString(e));
+ }
}
}
+ private String printStackTraceToString(Throwable throwable) {
+ StringWriter writer = new StringWriter();
+ throwable.printStackTrace(new PrintWriter(writer));
+ return writer.toString();
+ }
+
+
public void test_isInputShutdown() throws IOException {
Socket theSocket = new Socket();
ServerSocket serverSocket = new ServerSocket(0, 5);
diff --git a/support/src/test/java/libcore/java/security/CpuFeatures.java b/support/src/test/java/libcore/java/security/CpuFeatures.java
index 4c4c8a00..8ab610f 100644
--- a/support/src/test/java/libcore/java/security/CpuFeatures.java
+++ b/support/src/test/java/libcore/java/security/CpuFeatures.java
@@ -44,7 +44,7 @@
}
} else if (instructionSet.startsWith("x86")) {
// x86 CPUs with the "aes" flag and running in 64bit mode should have hardware AES.
- if (VMRuntime.is64BitInstructionSet(instructionSet)) {
+ if ("x86_64".equals(instructionSet)) {
List<String> flags = getListFromCpuinfo("flags");
if (flags != null && flags.contains("aes")) {
return true;