crypto: prevent Sign::SignFinal from crashing
The validation logic could be tricked into assuming an option was valid using malicious getters, leading to an invalid value being passed to the C++ layer, thus crashing the process. PR-URL: https://github.com/nodejs/node/pull/21815 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
This commit is contained in:
parent
3504850a00
commit
43cc6bc9f3
@ -57,10 +57,11 @@ function getSaltLength(options) {
|
|||||||
|
|
||||||
function getIntOption(name, defaultValue, options) {
|
function getIntOption(name, defaultValue, options) {
|
||||||
if (options.hasOwnProperty(name)) {
|
if (options.hasOwnProperty(name)) {
|
||||||
if (options[name] === options[name] >> 0) {
|
const value = options[name];
|
||||||
return options[name];
|
if (value === value >> 0) {
|
||||||
|
return value;
|
||||||
} else {
|
} else {
|
||||||
throw new ERR_INVALID_OPT_VALUE(name, options[name]);
|
throw new ERR_INVALID_OPT_VALUE(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user