summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-10-13 00:59:35 -0400
committercjihrig <cjihrig@gmail.com>2018-10-17 12:51:20 -0400
commitb94ce575f57fa883b93ce8948730577a9bde8603 (patch)
treef23776c5e00f737c8c7f2a9474f5ad3cc1024d11
parente2f58c71ddf0f91256cc85e6bb226a068256c5eb (diff)
downloadandroid-node-v8-b94ce575f57fa883b93ce8948730577a9bde8603.tar.gz
android-node-v8-b94ce575f57fa883b93ce8948730577a9bde8603.tar.bz2
android-node-v8-b94ce575f57fa883b93ce8948730577a9bde8603.zip
tls: prevent multiple connection errors
onConnectEnd(), which is called by TLSSocket, has a guard to prevent being called multiple times, but it does not prevent the OpenSSL error handler from being called, leading to multiple error events. This commit adds that piece of missing logic. PR-URL: https://github.com/nodejs/node/pull/23636 Fixes: https://github.com/nodejs/node/issues/23631 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Wyatt Preul <wpreul@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r--lib/_tls_wrap.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index fb9662c922..b28e3b62b7 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -248,9 +248,11 @@ function onocspresponse(resp) {
function onerror(err) {
const owner = this[owner_symbol];
- if (owner._writableState.errorEmitted)
+ if (owner._hadError)
return;
+ owner._hadError = true;
+
// Destroy socket if error happened before handshake's finish
if (!owner._secureEstablished) {
// When handshake fails control is not yet released,
@@ -265,8 +267,6 @@ function onerror(err) {
// Throw error
owner._emitTLSError(err);
}
-
- owner._writableState.errorEmitted = true;
}
function initRead(tls, wrapped) {