From a9ed26081c4388271d2f7969d5e376c1d5e61052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 23 Nov 2023 00:12:40 +0000 Subject: [PATCH] src: assert return value of BN_bn2binpad Every other invocation of BN_bn2binpad checks the return value. For safety and consistency, do so in RandomPrimeTraits::EncodeOutput() as well. --- src/crypto/crypto_random.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/crypto/crypto_random.cc b/src/crypto/crypto_random.cc index 245f3529186964..48154df7dc91ed 100644 --- a/src/crypto/crypto_random.cc +++ b/src/crypto/crypto_random.cc @@ -75,10 +75,10 @@ Maybe RandomPrimeTraits::EncodeOutput( size_t size = BN_num_bytes(params.prime.get()); std::shared_ptr store = ArrayBuffer::NewBackingStore(env->isolate(), size); - BN_bn2binpad( - params.prime.get(), - reinterpret_cast(store->Data()), - size); + CHECK_EQ(static_cast(size), + BN_bn2binpad(params.prime.get(), + reinterpret_cast(store->Data()), + size)); *result = ArrayBuffer::New(env->isolate(), store); return Just(true); }