Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
crypto: fix memory leak in SetDHParam
  • Loading branch information
skomski committed Aug 14, 2015
commit cc8ac7a762ec246a6c60c984dd6ef92bfd84a506
6 changes: 4 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
return;

const int keylen = BN_num_bits(dh->p);
if (keylen < 1024)
if (keylen < 1024) {
DH_free(dh);
return env->ThrowError("DH parameter is less than 1024 bits");
else if (keylen < 2048)
} else if (keylen < 2048) {
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
}

SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);
int r = SSL_CTX_set_tmp_dh(sc->ctx_, dh);
Expand Down