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
fix bug when len = 1
  • Loading branch information
danbev committed May 5, 2017
commit e7da72fa488dd7a60f24e26373b24054968b19d7
4 changes: 2 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
SecureContext* sc;
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());

bool has_password = true;
unsigned int len = args.Length();
if (len < 1) {
return env->ThrowError("Private key argument is mandatory");
Expand All @@ -474,7 +473,8 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
return env->ThrowError("Only private key and pass phrase are expected");
}

if (len == 2) {
bool has_password = len == 2;
if (has_password) {
if (args[1]->IsUndefined() || args[1]->IsNull())
has_password = false;
else
Expand Down