Skip to content
Prev Previous commit
Next Next commit
fixup! src: throw ERR_MISSING_ARGS in node_crypto.cc
  • Loading branch information
joyeecheung committed Apr 18, 2018
commit 184e8eaa24944ef4794e2648f330d7f597f606a4
38 changes: 15 additions & 23 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,7 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {

unsigned int len = args.Length();
if (len < 1) {
return node::THROW_ERR_MISSING_ARGS(env,
"Private key argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "Private key argument is mandatory");
}

if (len > 2) {
Expand Down Expand Up @@ -693,8 +692,7 @@ void SecureContext::SetCert(const FunctionCallbackInfo<Value>& args) {
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());

if (args.Length() != 1) {
return node::THROW_ERR_MISSING_ARGS(env,
"Certificate argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "Certificate argument is mandatory");
}

BIO* bio = LoadBIO(env, args[0]);
Expand Down Expand Up @@ -768,8 +766,7 @@ void SecureContext::AddCACert(const FunctionCallbackInfo<Value>& args) {
ClearErrorOnReturn clear_error_on_return;

if (args.Length() != 1) {
return node::THROW_ERR_MISSING_ARGS(env,
"CA certificate argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "CA certificate argument is mandatory");
}

BIO* bio = LoadBIO(env, args[0]);
Expand Down Expand Up @@ -800,7 +797,7 @@ void SecureContext::AddCRL(const FunctionCallbackInfo<Value>& args) {
ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());

if (args.Length() != 1) {
return node::THROW_ERR_MISSING_ARGS(env, "CRL argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "CRL argument is mandatory");
}

ClearErrorOnReturn clear_error_on_return;
Expand Down Expand Up @@ -903,7 +900,7 @@ void SecureContext::SetCiphers(const FunctionCallbackInfo<Value>& args) {
ClearErrorOnReturn clear_error_on_return;

if (args.Length() != 1) {
return node::THROW_ERR_MISSING_ARGS(env, "Ciphers argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "Ciphers argument is mandatory");
}

THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "Ciphers");
Expand All @@ -919,8 +916,7 @@ void SecureContext::SetECDHCurve(const FunctionCallbackInfo<Value>& args) {
Environment* env = sc->env();

if (args.Length() != 1)
return node::THROW_ERR_MISSING_ARGS(
env, "ECDH curve name argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "ECDH curve name argument is mandatory");

THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "ECDH curve name");

Expand All @@ -943,7 +939,7 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
// Auto DH is not supported in openssl 1.0.1, so dhparam needs
// to be specified explicitly
if (args.Length() != 1)
return node::THROW_ERR_MISSING_ARGS(env, "DH argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "DH argument is mandatory");

// Invalid dhparam is silently discarded and DHE is no longer used.
BIO* bio = LoadBIO(env, args[0]);
Expand Down Expand Up @@ -998,7 +994,7 @@ void SecureContext::SetSessionIdContext(
Environment* env = sc->env();

if (args.Length() != 1) {
return node::THROW_ERR_MISSING_ARGS(
return THROW_ERR_MISSING_ARGS(
env, "Session ID context argument is mandatory");
}

Expand Down Expand Up @@ -1070,8 +1066,7 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo<Value>& args) {
ClearErrorOnReturn clear_error_on_return;

if (args.Length() < 1) {
return node::THROW_ERR_MISSING_ARGS(
env, "PFX certificate argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "PFX certificate argument is mandatory");
}

in = LoadBIO(env, args[0]);
Expand Down Expand Up @@ -1204,8 +1199,7 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {
Environment* env = wrap->env();

if (args.Length() < 1) {
return node::THROW_ERR_MISSING_ARGS(
env, "Ticket keys argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "Ticket keys argument is mandatory");
}

THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Ticket keys");
Expand Down Expand Up @@ -1958,7 +1952,7 @@ void SSLWrap<Base>::SetSession(const FunctionCallbackInfo<Value>& args) {
ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder());

if (args.Length() < 1) {
return node::THROW_ERR_MISSING_ARGS(env, "Session argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "Session argument is mandatory");
}

THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Session");
Expand Down Expand Up @@ -2083,8 +2077,7 @@ void SSLWrap<Base>::SetOCSPResponse(
Environment* env = w->env();

if (args.Length() < 1)
return node::THROW_ERR_MISSING_ARGS(
env, "OCSP response argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "OCSP response argument is mandatory");

THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "OCSP response");

Expand Down Expand Up @@ -4092,8 +4085,7 @@ void DiffieHellman::DiffieHellmanGroup(
DiffieHellman* diffieHellman = new DiffieHellman(env, args.This());

if (args.Length() != 1) {
return node::THROW_ERR_MISSING_ARGS(
env, "Group name argument is mandatory");
return THROW_ERR_MISSING_ARGS(env, "Group name argument is mandatory");
}

THROW_AND_RETURN_IF_NOT_STRING(env, args[0], "Group name");
Expand Down Expand Up @@ -4243,7 +4235,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
BIGNUM* key = nullptr;

if (args.Length() == 0) {
return node::THROW_ERR_MISSING_ARGS(
return THROW_ERR_MISSING_ARGS(
env, "Other party's public key argument is mandatory");
} else {
THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Other party's public key");
Expand Down Expand Up @@ -4314,7 +4306,7 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,

if (args.Length() == 0) {
snprintf(errmsg, sizeof(errmsg), "%s argument is mandatory", what);
return node::THROW_ERR_MISSING_ARGS(env, errmsg);
return THROW_ERR_MISSING_ARGS(env, errmsg);
}

if (!Buffer::HasInstance(args[0])) {
Expand Down