Skip to content

Commit 74b3023

Browse files
panvaaduh95
authored andcommitted
crypto: handle XOF output allocation failure
Return an operation error when XOF output allocation fails. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64851 Backport-PR-URL: #65087 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 782ad5d commit 74b3023

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/crypto/crypto_turboshake.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,10 @@ bool TurboShakeTraits::DeriveBits(Environment* env,
468468
ByteSource* out,
469469
CryptoJobMode mode) {
470470
CHECK_GT(params.output_length, 0);
471-
char* buf = MallocOpenSSL<char>(params.output_length);
471+
char* buf = static_cast<char*>(OPENSSL_malloc(params.output_length));
472+
if (buf == nullptr) {
473+
return false;
474+
}
472475

473476
const uint8_t* input = reinterpret_cast<const uint8_t*>(params.data.data());
474477
size_t input_len = params.data.size();
@@ -592,7 +595,10 @@ bool KangarooTwelveTraits::DeriveBits(Environment* env,
592595
return false;
593596
}
594597

595-
char* buf = MallocOpenSSL<char>(params.output_length);
598+
char* buf = static_cast<char*>(OPENSSL_malloc(params.output_length));
599+
if (buf == nullptr) {
600+
return false;
601+
}
596602

597603
switch (params.variant) {
598604
case KangarooTwelveVariant::KT128:

0 commit comments

Comments
 (0)