Skip to content

Commit

Permalink
src: remove unnecessary comment and add a CHECK in crypto_tls.cc
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Sen <[email protected]>

PR-URL: #39991
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
RaisinTen authored and BethGriggs committed Sep 21, 2021
1 parent 8d5787a commit 95528b2
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/crypto/crypto_tls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,19 @@ int NewSessionCallback(SSL* s, SSL_SESSION* sess) {
return 0;

// Serialize session
// TODO(@jasnell): An AllocatedBuffer or BackingStore would be better
// here to start eliminating unnecessary uses of Buffer where an ordinary
// Uint8Array would do just fine.
Local<Object> session = Buffer::New(env, size).FromMaybe(Local<Object>());
if (UNLIKELY(session.IsEmpty()))
return 0;

unsigned char* session_data =
reinterpret_cast<unsigned char*>(Buffer::Data(session));

memset(session_data, 0, size);
i2d_SSL_SESSION(sess, &session_data);
CHECK_EQ(i2d_SSL_SESSION(sess, &session_data), size);

unsigned int session_id_length;
const unsigned char* session_id_data =
SSL_SESSION_get_id(sess, &session_id_length);

// TODO(@jasnell): An AllocatedBuffer or BackingStore would be better
// here to start eliminating unnecessary uses of Buffer where an ordinary
// Uint8Array would do just fine
Local<Object> session_id = Buffer::Copy(
env,
reinterpret_cast<const char*>(session_id_data),
Expand Down

0 comments on commit 95528b2

Please sign in to comment.