Bug 733521: Hold handshake lock across all accesses of handshake information in ssl3_GatherCompleteHandshake, r=wtc
--- a/lib/ssl/ssl3gthr.c
+++ b/lib/ssl/ssl3gthr.c
@@ -276,44 +276,43 @@ ssl3_GatherCompleteHandshake(sslSocket *
SSL3Ciphertext cText;
int rv;
PRBool canFalseStart = PR_FALSE;
SSL_TRC(30, ("ssl3_GatherCompleteHandshake"));
PORT_Assert( ss->opt.noLocks || ssl_HaveRecvBufLock(ss) );
do {
- PRBool handleRecordNow;
+ PRBool handleRecordNow = PR_FALSE;
ssl_GetSSL3HandshakeLock(ss);
/* Without this, we may end up wrongly reporting
* SSL_ERROR_RX_UNEXPECTED_* errors if we receive any records from the
* peer while we are waiting to be restarted.
*/
- rv = ss->ssl3.hs.restartTarget == NULL ? SECSuccess : SECFailure;
- if (rv != SECSuccess) {
+ if (ss->ssl3.hs.restartTarget) {
ssl_ReleaseSSL3HandshakeLock(ss);
PORT_SetError(PR_WOULD_BLOCK_ERROR);
return (int) SECFailure;
}
/* Treat an empty msgState like a NULL msgState. (Most of the time
* when ssl3_HandleHandshake returns SECWouldBlock, it leaves
* behind a non-NULL but zero-length msgState).
* Test: async_cert_restart_server_sends_hello_request_first_in_separate_record
*/
- if (ss->ssl3.hs.msgState.buf != NULL) {
+ if (ss->ssl3.hs.msgState.buf) {
if (ss->ssl3.hs.msgState.len == 0) {
ss->ssl3.hs.msgState.buf = NULL;
+ } else {
+ handleRecordNow = PR_TRUE;
}
}
- handleRecordNow = ss->ssl3.hs.msgState.buf != NULL;
-
ssl_ReleaseSSL3HandshakeLock(ss);
if (handleRecordNow) {
/* ssl3_HandleHandshake previously returned SECWouldBlock and the
* as-yet-unprocessed plaintext of that previous handshake record.
* We need to process it now before we overwrite it with the next
* handshake record.
*/