From 2162219299644197269db7af70c5e62ae1330e92 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 21 May 2016 12:28:52 -0400 Subject: [PATCH] Add call to ThrowIfInvalidTruncatedSize in TruncatedFinal --- blake2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blake2.cpp b/blake2.cpp index 6409f6a8..7f0933a6 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -422,9 +422,10 @@ void BLAKE2_Base::Update(const byte *input, size_t length) template void BLAKE2_Base::TruncatedFinal(byte *hash, size_t size) { - State& state = *m_state; + this->ThrowIfInvalidTruncatedSize(size); // Set last block unconditionally + State& state = *m_state; state.f[0] = static_cast(-1); // Set last node if tree mode @@ -438,7 +439,7 @@ void BLAKE2_Base::TruncatedFinal(byte *hash, size_t size) Compress(state.buffer); // Copy to caller buffer - memcpy_s(hash, size, &state.h[0], DIGESTSIZE); + memcpy_s(hash, size, &state.h[0], size); Restart(); }