Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clear errors on return
  • Loading branch information
petkaantonov committed Feb 13, 2016
commit 67d7af5fc6fc54eb47ac7264dbeb4f1125af869a
21 changes: 21 additions & 0 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4724,6 +4724,9 @@ void ECDH::New(const FunctionCallbackInfo<Value>& args) {
void ECDH::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence compiler warning.

ECDH* ecdh = Unwrap<ECDH>(args.Holder());

if (!EC_KEY_generate_key(ecdh->key_))
Expand All @@ -4735,6 +4738,9 @@ EC_POINT* ECDH::BufferToPoint(char* data, size_t len) {
EC_POINT* pub;
int r;

ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence compiler warning.

pub = EC_POINT_new(group_);
if (pub == nullptr) {
env()->ThrowError("Failed to allocate EC_POINT for a public key");
Expand Down Expand Up @@ -4763,6 +4769,9 @@ EC_POINT* ECDH::BufferToPoint(char* data, size_t len) {
void ECDH::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence compiler warning.

THROW_AND_RETURN_IF_NOT_BUFFER(args[0]);

ECDH* ecdh = Unwrap<ECDH>(args.Holder());
Expand Down Expand Up @@ -4796,6 +4805,9 @@ void ECDH::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
void ECDH::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence compiler warning.

// Conversion form
CHECK_EQ(args.Length(), 1);

Expand Down Expand Up @@ -4831,6 +4843,9 @@ void ECDH::GetPublicKey(const FunctionCallbackInfo<Value>& args) {
void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence compiler warning.

ECDH* ecdh = Unwrap<ECDH>(args.Holder());

const BIGNUM* b = EC_KEY_get0_private_key(ecdh->key_);
Expand All @@ -4855,6 +4870,9 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence compiler warning.

ECDH* ecdh = Unwrap<ECDH>(args.Holder());

THROW_AND_RETURN_IF_NOT_BUFFER(args[0]);
Expand Down Expand Up @@ -4908,6 +4926,9 @@ void ECDH::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
void ECDH::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

ClearErrorOnReturn clear_error_on_return;
(void) &clear_error_on_return; // Silence compiler warning.

ECDH* ecdh = Unwrap<ECDH>(args.Holder());

THROW_AND_RETURN_IF_NOT_BUFFER(args[0]);
Expand Down