Skip to content

Commit

Permalink
crypto: remove INT_MAX restriction in randomBytes
Browse files Browse the repository at this point in the history
This restriction was due to an implementation detail in CSPRNG(). Now
that CSPRNG() properly handles lengths exceeding INT_MAX, remove this
artificial restriction.

Refs: nodejs#47515
  • Loading branch information
tniessen committed Apr 14, 2023
1 parent cd0fcf2 commit 3d7f4ee
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/crypto/crypto_random.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Maybe<bool> RandomBytesTraits::AdditionalConfig(
const FunctionCallbackInfo<Value>& 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
Expand All @@ -52,11 +51,6 @@ Maybe<bool> 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<bool>();
}

params->buffer = in.data() + byte_offset;
params->size = size;

Expand Down

0 comments on commit 3d7f4ee

Please sign in to comment.