Skip to content

Commit

Permalink
src: assert return value of BN_bn2binpad
Browse files Browse the repository at this point in the history
Every other invocation of BN_bn2binpad checks the return value. For
safety and consistency, do so in RandomPrimeTraits::EncodeOutput()
as well.

PR-URL: #50860
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
tniessen authored and UlisesGascon committed Dec 19, 2023
1 parent f4070dd commit 07a4e94
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/crypto/crypto_random.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ Maybe<bool> RandomPrimeTraits::EncodeOutput(
size_t size = BN_num_bytes(params.prime.get());
std::shared_ptr<BackingStore> store =
ArrayBuffer::NewBackingStore(env->isolate(), size);
BN_bn2binpad(
params.prime.get(),
reinterpret_cast<unsigned char*>(store->Data()),
size);
CHECK_EQ(static_cast<int>(size),
BN_bn2binpad(params.prime.get(),
reinterpret_cast<unsigned char*>(store->Data()),
size));
*result = ArrayBuffer::New(env->isolate(), store);
return Just(true);
}
Expand Down

0 comments on commit 07a4e94

Please sign in to comment.