-
Notifications
You must be signed in to change notification settings - Fork 30k
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: add getCurves() to get supported ECs #1914
Conversation
👍 nice feature, will be pretty useful. Looking good from my side, though I can't review the C++ part. |
/cc @nodejs/crypto |
Looks like one of the Windows CI boxes has too little memory? |
EC_builtin_curve* curves = | ||
reinterpret_cast<EC_builtin_curve*>(malloc(sizeof(EC_builtin_curve) * len)); | ||
|
||
if (curves) { |
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.
Won't this just fail silently if you run out of memory in the malloc
call? Perhaps something like this would be simpler.
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.
Fixed
Local<Array> arr = Array::New(env->isolate()); | ||
size_t len = EC_get_builtin_curves(NULL, 0); | ||
EC_builtin_curve* curves = | ||
reinterpret_cast<EC_builtin_curve*>(malloc(sizeof(EC_builtin_curve) * len)); |
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.
Style: four spaces indent for line continuations and can you use sizeof(*curves)
?
Commit updated as per suggestions. |
|
||
if (num_curves) { | ||
alloc_size = sizeof(*curves) * num_curves; | ||
curves = reinterpret_cast<EC_builtin_curve*>(malloc(alloc_size)); |
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.
Micro-nit: just static_cast
is sufficient here.
LGTM with nits. |
PR-URL: #1914 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Landed in 38d1afc. |
May as well update the doc change in deb8b87 again to point to this method. |
No description provided.