--- a/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java Thu Jun 07 23:53:56 2018 +0800
+++ b/src/java.base/share/classes/sun/security/ssl/SSLSocketInputRecord.java Thu Jun 07 09:30:42 2018 -0700
@@ -25,12 +25,18 @@
package sun.security.ssl;
-import java.io.*;
-import java.nio.*;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import javax.crypto.BadPaddingException;
-import javax.net.ssl.*;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.SSLProtocolException;
+
import sun.security.ssl.SSLCipher.SSLReadCipher;
/**
@@ -43,11 +49,6 @@
private OutputStream os = null;
private final byte[] temporary = new byte[1024];
- // used by handshake hash computation for handshake fragment
- private byte prevType = -1;
- private int hsMsgOff = 0;
- private int hsMsgLen = 0;
-
private boolean formatVerified = false; // SSLv2 ruled out?
// Cache for incomplete handshake messages.
@@ -78,7 +79,7 @@
/*
* If we have already verified previous packets, we can
* ignore the verifications steps, and jump right to the
- * determination. Otherwise, try one last hueristic to
+ * determination. Otherwise, try one last heuristic to
* see if it's SSL/TLS.
*/
if (formatVerified ||
@@ -180,7 +181,7 @@
}
}
- // The record header should has comsumed.
+ // The record header should has consumed.
hasHeader = false;
return decodeInputRecord(temporary);
}
@@ -263,7 +264,8 @@
throw (SSLProtocolException)(new SSLProtocolException(
"Unexpected exception")).initCause(gse);
}
- if (contentType != ContentType.HANDSHAKE.id && hsMsgOff != hsMsgLen) {
+ if (contentType != ContentType.HANDSHAKE.id &&
+ handshakeBuffer != null && handshakeBuffer.hasRemaining()) {
throw new SSLProtocolException(
"Expected to get a handshake fragment");
}