src: throw ERR_INVALID_ARG_VALUE in node_crypto.cc
PR-URL: https://github.com/nodejs/node/pull/20121 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
02dc307ae2
commit
a82902f087
@ -956,7 +956,8 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
|
|||||||
DH_get0_pqg(dh, &p, nullptr, nullptr);
|
DH_get0_pqg(dh, &p, nullptr, nullptr);
|
||||||
const int size = BN_num_bits(p);
|
const int size = BN_num_bits(p);
|
||||||
if (size < 1024) {
|
if (size < 1024) {
|
||||||
return env->ThrowError("DH parameter is less than 1024 bits");
|
return THROW_ERR_INVALID_ARG_VALUE(
|
||||||
|
env, "DH parameter is less than 1024 bits");
|
||||||
} else if (size < 2048) {
|
} else if (size < 2048) {
|
||||||
args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(
|
args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(
|
||||||
env->isolate(), "DH parameter is less than 2048 bits"));
|
env->isolate(), "DH parameter is less than 2048 bits"));
|
||||||
@ -1203,7 +1204,8 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo<Value>& args) {
|
|||||||
THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Ticket keys");
|
THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "Ticket keys");
|
||||||
|
|
||||||
if (Buffer::Length(args[0]) != 48) {
|
if (Buffer::Length(args[0]) != 48) {
|
||||||
return env->ThrowTypeError("Ticket keys length must be 48 bytes");
|
return THROW_ERR_INVALID_ARG_VALUE(
|
||||||
|
env, "Ticket keys length must be 48 bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(wrap->ticket_key_name_, Buffer::Data(args[0]), 16);
|
memcpy(wrap->ticket_key_name_, Buffer::Data(args[0]), 16);
|
||||||
@ -4390,7 +4392,8 @@ void ECDH::New(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
int nid = OBJ_sn2nid(*curve);
|
int nid = OBJ_sn2nid(*curve);
|
||||||
if (nid == NID_undef)
|
if (nid == NID_undef)
|
||||||
return env->ThrowTypeError("First argument should be a valid curve name");
|
return THROW_ERR_INVALID_ARG_VALUE(env,
|
||||||
|
"First argument should be a valid curve name");
|
||||||
|
|
||||||
EC_KEY* key = EC_KEY_new_by_curve_name(nid);
|
EC_KEY* key = EC_KEY_new_by_curve_name(nid);
|
||||||
if (key == nullptr)
|
if (key == nullptr)
|
||||||
|
@ -19,6 +19,7 @@ namespace node {
|
|||||||
#define ERRORS_WITH_CODE(V) \
|
#define ERRORS_WITH_CODE(V) \
|
||||||
V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
|
V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
|
||||||
V(ERR_INDEX_OUT_OF_RANGE, RangeError) \
|
V(ERR_INDEX_OUT_OF_RANGE, RangeError) \
|
||||||
|
V(ERR_INVALID_ARG_VALUE, TypeError) \
|
||||||
V(ERR_INVALID_ARG_TYPE, TypeError) \
|
V(ERR_INVALID_ARG_TYPE, TypeError) \
|
||||||
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
|
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
|
||||||
V(ERR_MISSING_MODULE, Error) \
|
V(ERR_MISSING_MODULE, Error) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user