diff options
author | Adam Vartanian <flooey@google.com> | 2018-02-28 17:11:56 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-02-28 17:11:56 +0000 |
commit | 4cf5056b33e008d760e6d194028a048dbc71eba0 (patch) | |
tree | be78f5dd29a383da99fbe419bc6b9b919df09816 | |
parent | c432e46046499c6f79da5e56a50861644a9c6701 (diff) | |
parent | 7e5fb7c809ec5f7130e94a54f7c08b9bfa035de4 (diff) | |
download | conscrypt-4cf5056b33e008d760e6d194028a048dbc71eba0.tar.gz |
Merge upstream master
am: 7e5fb7c809
Change-Id: I3637f72dd07a932df32cb89c71dfbfb8e29d4a6a
-rw-r--r-- | common/src/jni/main/cpp/conscrypt/native_crypto.cc | 8 | ||||
-rw-r--r-- | openjdk-integ-tests/src/test/java/org/conscrypt/javax/net/ssl/SSLSocketTest.java | 12 |
2 files changed, 13 insertions, 7 deletions
diff --git a/common/src/jni/main/cpp/conscrypt/native_crypto.cc b/common/src/jni/main/cpp/conscrypt/native_crypto.cc index d2955403..053315e1 100644 --- a/common/src/jni/main/cpp/conscrypt/native_crypto.cc +++ b/common/src/jni/main/cpp/conscrypt/native_crypto.cc @@ -7886,12 +7886,10 @@ static int sslRead(JNIEnv* env, SSL* ssl, jobject fdObject, jobject shc, char* b // A problem occurred during a system call, but this is not // necessarily an error. case SSL_ERROR_SYSCALL: { - // Connection closed without proper shutdown. Throw a SocketException to - // indicate that the socket is closed. + // Connection closed without proper shutdown. Tell caller we + // have reached end-of-stream. if (result == 0) { - conscrypt::jniutil::throwException(env, "java/net/SocketException", - "Socket closed"); - return THROWN_EXCEPTION; + return -1; } // System call has been interrupted. Simply retry. diff --git a/openjdk-integ-tests/src/test/java/org/conscrypt/javax/net/ssl/SSLSocketTest.java b/openjdk-integ-tests/src/test/java/org/conscrypt/javax/net/ssl/SSLSocketTest.java index f224a0a6..930f4aef 100644 --- a/openjdk-integ-tests/src/test/java/org/conscrypt/javax/net/ssl/SSLSocketTest.java +++ b/openjdk-integ-tests/src/test/java/org/conscrypt/javax/net/ssl/SSLSocketTest.java @@ -1955,8 +1955,16 @@ public class SSLSocketTest { // Read from the socket. try { toRead.setSoTimeout(readingTimeoutMillis); - toRead.getInputStream().read(); - fail(); + int read = toRead.getInputStream().read(); + // In the case of reading the wrapper and closing the underlying socket, + // there is a race condition between the reading thread being woken and + // reading the socket again and the closing thread marking the file descriptor + // as invalid. If the latter happens first, a SocketException is thrown, + // but if the former happens first it just looks like the peer closed the + // connection and a -1 return is acceptable. + if (read != -1 || readUnderlying || !closeUnderlying) { + fail(); + } } catch (SocketTimeoutException e) { throw e; } catch (IOException expected) { |