From f6b2ea8bb9825bf585155fc58ed6d48e4a4b2929 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Wed, 19 Dec 2018 14:45:51 -0800 Subject: [PATCH] tls: do not confuse session and session ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit session ID was named session in C++ and key in JS, Name them after what they are, as the 'newSession' event docs do. PR-URL: https://github.com/nodejs/node/pull/25153 Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Anatoli Papirovski --- lib/_tls_wrap.js | 4 ++-- src/node_crypto.cc | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 271afd73a97998..9ac17cd0b0fafe 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -212,7 +212,7 @@ function requestOCSPDone(socket) { } -function onnewsession(key, session) { +function onnewsession(sessionId, session) { const owner = this[owner_symbol]; if (!owner.server) @@ -236,7 +236,7 @@ function onnewsession(key, session) { }; owner._newSessionPending = true; - if (!owner.server.emit('newSession', key, session, done)) + if (!owner.server.emit('newSession', sessionId, session, done)) done(); } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 618fe14ae92c07..30e9eb49b64ab1 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1483,20 +1483,20 @@ int SSLWrap::NewSessionCallback(SSL* s, SSL_SESSION* sess) { return 0; // Serialize session - Local buff = Buffer::New(env, size).ToLocalChecked(); - unsigned char* serialized = reinterpret_cast( - Buffer::Data(buff)); - memset(serialized, 0, size); - i2d_SSL_SESSION(sess, &serialized); + Local session = Buffer::New(env, size).ToLocalChecked(); + unsigned char* session_data = reinterpret_cast( + Buffer::Data(session)); + memset(session_data, 0, size); + i2d_SSL_SESSION(sess, &session_data); unsigned int session_id_length; - const unsigned char* session_id = SSL_SESSION_get_id(sess, - &session_id_length); - Local session = Buffer::Copy( + const unsigned char* session_id_data = SSL_SESSION_get_id(sess, + &session_id_length); + Local session_id = Buffer::Copy( env, - reinterpret_cast(session_id), + reinterpret_cast(session_id_data), session_id_length).ToLocalChecked(); - Local argv[] = { session, buff }; + Local argv[] = { session_id, session }; w->new_session_wait_ = true; w->MakeCallback(env->onnewsession_string(), arraysize(argv), argv);