From e2292f936e8d0c289504b6a91d4a3668cd9a05af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 17 Apr 2023 19:26:02 +0200 Subject: [PATCH] crypto: remove INT_MAX restriction in randomBytes This restriction was due to an implementation detail in CSPRNG(). Now that CSPRNG() properly handles lengths exceeding INT_MAX, remove this artificial restriction. Refs: https://github.com/nodejs/node/pull/47515 PR-URL: https://github.com/nodejs/node/pull/47559 Reviewed-By: Yagiz Nizipli Reviewed-By: Filip Skokan --- src/crypto/crypto_random.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/crypto/crypto_random.cc b/src/crypto/crypto_random.cc index 272dbdaf7c9125..9850104cd607f8 100644 --- a/src/crypto/crypto_random.cc +++ b/src/crypto/crypto_random.cc @@ -39,7 +39,6 @@ Maybe RandomBytesTraits::AdditionalConfig( const FunctionCallbackInfo& args, unsigned int offset, RandomBytesConfig* params) { - Environment* env = Environment::GetCurrent(args); CHECK(IsAnyByteSource(args[offset])); // Buffer to fill CHECK(args[offset + 1]->IsUint32()); // Offset CHECK(args[offset + 2]->IsUint32()); // Size @@ -51,11 +50,6 @@ Maybe RandomBytesTraits::AdditionalConfig( CHECK_GE(byte_offset + size, byte_offset); // Overflow check. CHECK_LE(byte_offset + size, in.size()); // Bounds check. - if (UNLIKELY(size > INT_MAX)) { - THROW_ERR_OUT_OF_RANGE(env, "buffer is too large"); - return Nothing(); - } - params->buffer = in.data() + byte_offset; params->size = size;