From 5d01b27cb394ec7443f37d8ebabed23d43548b30 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Tue, 1 Nov 2016 14:26:04 +0300 Subject: [PATCH] crypto: use check macros in CipherBase::SetAuthTag --- src/node_crypto.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 25cb003d39e90a..c3fae0484f7d3b 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3363,15 +3363,12 @@ bool CipherBase::SetAuthTag(const char* data, unsigned int len) { void CipherBase::SetAuthTag(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); - Local buf = args[0].As(); - - if (!buf->IsObject() || !Buffer::HasInstance(buf)) - return env->ThrowTypeError("Auth tag must be a Buffer"); + THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "Auth tag"); CipherBase* cipher; ASSIGN_OR_RETURN_UNWRAP(&cipher, args.Holder()); - if (!cipher->SetAuthTag(Buffer::Data(buf), Buffer::Length(buf))) + if (!cipher->SetAuthTag(Buffer::Data(args[0]), Buffer::Length(args[0]))) env->ThrowError("Attempting to set auth tag in unsupported state"); }