Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 25bc7fe

Browse filesBrowse files
bnoordhuisFishrock123
authored andcommitted
src: remove unused md_ data members
The code assigned the result of EVP_get_digestbyname() to data members called md_ that were not used outside the initialization functions. PR-URL: #7374 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
1 parent 2228a65 commit 25bc7fe
Copy full SHA for 25bc7fe

File tree

Expand file treeCollapse file tree

2 files changed

+17
-23
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-23
lines changed
Open diff view settings
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+17-17Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3585,17 +3585,17 @@ void Hmac::New(const FunctionCallbackInfo<Value>& args) {
35853585
void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) {
35863586
HandleScope scope(env()->isolate());
35873587

3588-
CHECK_EQ(md_, nullptr);
3589-
md_ = EVP_get_digestbyname(hash_type);
3590-
if (md_ == nullptr) {
3588+
CHECK_EQ(initialised_, false);
3589+
const EVP_MD* md = EVP_get_digestbyname(hash_type);
3590+
if (md == nullptr) {
35913591
return env()->ThrowError("Unknown message digest");
35923592
}
35933593
HMAC_CTX_init(&ctx_);
35943594
int result = 0;
35953595
if (key_len == 0) {
3596-
result = HMAC_Init(&ctx_, "", 0, md_);
3596+
result = HMAC_Init(&ctx_, "", 0, md);
35973597
} else {
3598-
result = HMAC_Init(&ctx_, key, key_len, md_);
3598+
result = HMAC_Init(&ctx_, key, key_len, md);
35993599
}
36003600
if (!result) {
36013601
return ThrowCryptoError(env(), ERR_get_error());
@@ -3730,12 +3730,12 @@ void Hash::New(const FunctionCallbackInfo<Value>& args) {
37303730

37313731

37323732
bool Hash::HashInit(const char* hash_type) {
3733-
CHECK_EQ(md_, nullptr);
3734-
md_ = EVP_get_digestbyname(hash_type);
3735-
if (md_ == nullptr)
3733+
CHECK_EQ(initialised_, false);
3734+
const EVP_MD* md = EVP_get_digestbyname(hash_type);
3735+
if (md == nullptr)
37363736
return false;
37373737
EVP_MD_CTX_init(&mdctx_);
3738-
if (EVP_DigestInit_ex(&mdctx_, md_, nullptr) <= 0) {
3738+
if (EVP_DigestInit_ex(&mdctx_, md, nullptr) <= 0) {
37393739
return false;
37403740
}
37413741
initialised_ = true;
@@ -3881,13 +3881,13 @@ void Sign::New(const FunctionCallbackInfo<Value>& args) {
38813881

38823882

38833883
SignBase::Error Sign::SignInit(const char* sign_type) {
3884-
CHECK_EQ(md_, nullptr);
3885-
md_ = EVP_get_digestbyname(sign_type);
3886-
if (!md_)
3884+
CHECK_EQ(initialised_, false);
3885+
const EVP_MD* md = EVP_get_digestbyname(sign_type);
3886+
if (md == nullptr)
38873887
return kSignUnknownDigest;
38883888

38893889
EVP_MD_CTX_init(&mdctx_);
3890-
if (!EVP_SignInit_ex(&mdctx_, md_, nullptr))
3890+
if (!EVP_SignInit_ex(&mdctx_, md, nullptr))
38913891
return kSignInit;
38923892
initialised_ = true;
38933893

@@ -4087,13 +4087,13 @@ void Verify::New(const FunctionCallbackInfo<Value>& args) {
40874087

40884088

40894089
SignBase::Error Verify::VerifyInit(const char* verify_type) {
4090-
CHECK_EQ(md_, nullptr);
4091-
md_ = EVP_get_digestbyname(verify_type);
4092-
if (md_ == nullptr)
4090+
CHECK_EQ(initialised_, false);
4091+
const EVP_MD* md = EVP_get_digestbyname(verify_type);
4092+
if (md == nullptr)
40934093
return kSignUnknownDigest;
40944094

40954095
EVP_MD_CTX_init(&mdctx_);
4096-
if (!EVP_VerifyInit_ex(&mdctx_, md_, nullptr))
4096+
if (!EVP_VerifyInit_ex(&mdctx_, md, nullptr))
40974097
return kSignInit;
40984098
initialised_ = true;
40994099

Collapse file

‎src/node_crypto.h‎

Copy file name to clipboardExpand all lines: src/node_crypto.h
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,14 +500,12 @@ class Hmac : public BaseObject {
500500

501501
Hmac(Environment* env, v8::Local<v8::Object> wrap)
502502
: BaseObject(env, wrap),
503-
md_(nullptr),
504503
initialised_(false) {
505504
MakeWeak<Hmac>(this);
506505
}
507506

508507
private:
509508
HMAC_CTX ctx_; /* coverity[member_decl] */
510-
const EVP_MD* md_; /* coverity[member_decl] */
511509
bool initialised_;
512510
};
513511

@@ -531,14 +529,12 @@ class Hash : public BaseObject {
531529

532530
Hash(Environment* env, v8::Local<v8::Object> wrap)
533531
: BaseObject(env, wrap),
534-
md_(nullptr),
535532
initialised_(false) {
536533
MakeWeak<Hash>(this);
537534
}
538535

539536
private:
540537
EVP_MD_CTX mdctx_; /* coverity[member_decl] */
541-
const EVP_MD* md_; /* coverity[member_decl] */
542538
bool initialised_;
543539
bool finalized_;
544540
};
@@ -557,7 +553,6 @@ class SignBase : public BaseObject {
557553

558554
SignBase(Environment* env, v8::Local<v8::Object> wrap)
559555
: BaseObject(env, wrap),
560-
md_(nullptr),
561556
initialised_(false) {
562557
}
563558

@@ -571,7 +566,6 @@ class SignBase : public BaseObject {
571566
void CheckThrow(Error error);
572567

573568
EVP_MD_CTX mdctx_; /* coverity[member_decl] */
574-
const EVP_MD* md_; /* coverity[member_decl] */
575569
bool initialised_;
576570
};
577571

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.