diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-09-11 13:27:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-11 13:27:07 +0900 |
commit | ef2d98fe11ffe467a31d2e30e3ae9738147b74e9 (patch) | |
tree | cfbf1b93aaa447833f2e3c789625091bbcae2e1a /ext/node/ops/crypto/mod.rs | |
parent | 1521adf5ed640832755e362abc64b32afd7dcc7d (diff) |
fix(ext/node): validate input lengths in `Cipheriv` and `Decipheriv` (#25570)
addresses the first part of #25279
Diffstat (limited to 'ext/node/ops/crypto/mod.rs')
-rw-r--r-- | ext/node/ops/crypto/mod.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/ext/node/ops/crypto/mod.rs b/ext/node/ops/crypto/mod.rs index 738437577..600d31558 100644 --- a/ext/node/ops/crypto/mod.rs +++ b/ext/node/ops/crypto/mod.rs @@ -220,13 +220,9 @@ pub fn op_node_create_cipheriv( #[string] algorithm: &str, #[buffer] key: &[u8], #[buffer] iv: &[u8], -) -> u32 { - state.resource_table.add( - match cipher::CipherContext::new(algorithm, key, iv) { - Ok(context) => context, - Err(_) => return 0, - }, - ) +) -> Result<u32, AnyError> { + let context = cipher::CipherContext::new(algorithm, key, iv)?; + Ok(state.resource_table.add(context)) } #[op2(fast)] @@ -292,13 +288,9 @@ pub fn op_node_create_decipheriv( #[string] algorithm: &str, #[buffer] key: &[u8], #[buffer] iv: &[u8], -) -> u32 { - state.resource_table.add( - match cipher::DecipherContext::new(algorithm, key, iv) { - Ok(context) => context, - Err(_) => return 0, - }, - ) +) -> Result<u32, AnyError> { + let context = cipher::DecipherContext::new(algorithm, key, iv)?; + Ok(state.resource_table.add(context)) } #[op2(fast)] |