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
PR-URL: nodejs#47559
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
  • Loading branch information
tniessen authored and MoLow committed Jul 6, 2023
1 parent 261e1d2 commit e2292f9
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 @@ -39,7 +39,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 @@ -51,11 +50,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 e2292f9

Please sign in to comment.