From 3d7f4eedf73cccb184b6ab8d02f0b617c8263f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Fri, 14 Apr 2023 11:41:43 +0000 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 --- 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 2652b7d8aae17a..953932ddd9a496 100644 --- a/src/crypto/crypto_random.cc +++ b/src/crypto/crypto_random.cc @@ -40,7 +40,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 @@ -52,11 +51,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;