diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2017-07-10 12:56:37 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2017-07-17 23:09:16 +0200 |
commit | 92f3e4d4873cf96ed2e5cc2b716a92bf7d23a9af (patch) | |
tree | bc47a9d9c9fe201fcf7485b5ea40109aba330171 /src/node_crypto.h | |
parent | ff2c57d9654cbe277a3827d1c02e8d2fd69bc29a (diff) | |
download | android-node-v8-92f3e4d4873cf96ed2e5cc2b716a92bf7d23a9af.tar.gz android-node-v8-92f3e4d4873cf96ed2e5cc2b716a92bf7d23a9af.tar.bz2 android-node-v8-92f3e4d4873cf96ed2e5cc2b716a92bf7d23a9af.zip |
src: don't heap allocate GCM cipher auth tag
Fix a memory leak by removing the heap allocation altogether.
Fixes: https://github.com/nodejs/node/issues/13917
PR-URL: https://github.com/nodejs/node/pull/14122
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_crypto.h')
-rw-r--r-- | src/node_crypto.h | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/src/node_crypto.h b/src/node_crypto.h index c1ba349d2d..db7a97920b 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -428,7 +428,6 @@ class CipherBase : public BaseObject { ~CipherBase() override { if (!initialised_) return; - delete[] auth_tag_; EVP_CIPHER_CTX_cleanup(&ctx_); } @@ -451,8 +450,6 @@ class CipherBase : public BaseObject { bool SetAutoPadding(bool auto_padding); bool IsAuthenticatedMode() const; - bool GetAuthTag(char** out, unsigned int* out_len) const; - bool SetAuthTag(const char* data, unsigned int len); bool SetAAD(const char* data, unsigned int len); static void New(const v8::FunctionCallbackInfo<v8::Value>& args); @@ -473,7 +470,6 @@ class CipherBase : public BaseObject { cipher_(nullptr), initialised_(false), kind_(kind), - auth_tag_(nullptr), auth_tag_len_(0) { MakeWeak<CipherBase>(this); } @@ -483,8 +479,8 @@ class CipherBase : public BaseObject { const EVP_CIPHER* cipher_; /* coverity[member_decl] */ bool initialised_; CipherKind kind_; - char* auth_tag_; unsigned int auth_tag_len_; + char auth_tag_[EVP_GCM_TLS_TAG_LEN]; }; class Hmac : public BaseObject { |