GeezerVison is showing github.com — crypto: handle XOF output allocation failure · nodejs/node@f61408b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/crypto/crypto_turboshake.cc +10-2Lines changed: 10 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -469,7 +469,11 @@ bool TurboShakeTraits::DeriveBits(Environment* env, |
469 | 469 | CryptoJobMode mode, |
470 | 470 | CryptoErrorStore* errors) { |
471 | 471 | CHECK_GT(params.output_length, 0); |
472 | | - char* buf = MallocOpenSSL<char>(params.output_length); |
| 472 | + char* buf = static_cast<char*>(OPENSSL_malloc(params.output_length)); |
| 473 | + if (buf == nullptr) { |
| 474 | + errors->Insert(NodeCryptoError::ALLOCATION_FAILED); |
| 475 | + return false; |
| 476 | + } |
473 | 477 |
|
474 | 478 | const uint8_t* input = reinterpret_cast<const uint8_t*>(params.data.data()); |
475 | 479 | size_t input_len = params.data.size(); |
@@ -595,7 +599,11 @@ bool KangarooTwelveTraits::DeriveBits(Environment* env, |
595 | 599 | return false; |
596 | 600 | } |
597 | 601 |
|
598 | | - char* buf = MallocOpenSSL<char>(params.output_length); |
| 602 | + char* buf = static_cast<char*>(OPENSSL_malloc(params.output_length)); |
| 603 | + if (buf == nullptr) { |
| 604 | + errors->Insert(NodeCryptoError::ALLOCATION_FAILED); |
| 605 | + return false; |
| 606 | + } |
599 | 607 |
|
600 | 608 | switch (params.variant) { |
601 | 609 | case KangarooTwelveVariant::KT128: |
|