-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto: fix checkPrime crash with large buffers #56559
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
5c3164a
to
9deab1f
Compare
@@ -176,6 +176,11 @@ Maybe<void> CheckPrimeTraits::AdditionalConfig( | |||
ArrayBufferOrViewContents<unsigned char> candidate(args[offset]); | |||
|
|||
params->candidate = BignumPointer(candidate.data(), candidate.size()); | |||
if (params->candidate.get() == nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simplified bool check should work here
if (params->candidate.get() == nullptr) { | |
if (!params->candidate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadn't noticed the bool
operator was implemented. Thanks!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56559 +/- ##
=======================================
Coverage 89.16% 89.16%
=======================================
Files 662 662
Lines 191751 191756 +5
Branches 36900 36906 +6
=======================================
+ Hits 170972 170981 +9
+ Misses 13635 13633 -2
+ Partials 7144 7142 -2
|
@@ -254,6 +255,18 @@ for (const checks of [-(2 ** 31), -1, 2 ** 31, 2 ** 32 - 1, 2 ** 32, 2 ** 50]) { | |||
}); | |||
} | |||
|
|||
{ | |||
const bytes = randomBytes(67108864); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is generating this large of a random number each time necessary? Should be possible to generate a value statically once that trips this error reliably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean storing the number into a file in fixtures and use that in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't need to be in fixtures (can just be defined inline here) but yes that would work.
Fixes: #56512