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 <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
tniessen authored and RafaelGSS committed Nov 29, 2023
1 parent 65a811a commit feb8ff9
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 feb8ff9

Please sign in to comment.