Skip to content

Commit

Permalink
Clear ECDH errors on return
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed Jul 15, 2015
1 parent d9c98e7 commit 0d10ae6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4275,6 +4275,9 @@ void ECDH::Initialize(Environment* env, Handle<Object> target) {
void ECDH::New(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

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

// TODO(indutny): Support raw curves?
CHECK(args[0]->IsString());
node::Utf8Value curve(env->isolate(), args[0]);
Expand All @@ -4294,6 +4297,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 @@ -4307,6 +4313,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 @@ -4335,6 +4344,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 @@ -4364,6 +4376,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 @@ -4402,6 +4417,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());

if (!ecdh->generated_)
Expand Down Expand Up @@ -4429,6 +4447,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 All @@ -4448,6 +4469,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

0 comments on commit 0d10ae6

Please sign in to comment.