From f55c0a210c826a449c79eacc674221ee20c62d9e Mon Sep 17 00:00:00 2001 From: Max Wittal Date: Wed, 15 Nov 2023 17:37:57 +0700 Subject: [PATCH] hash_t::random() clear random bytes buffer after using it --- src/hash_t.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hash_t.cpp b/src/hash_t.cpp index d2cc12cda..60270a111 100644 --- a/src/hash_t.cpp +++ b/src/hash_t.cpp @@ -28,7 +28,10 @@ hash_t hash_t::random() { std::vector seed(4096); ::randombytes_buf(seed.data(), seed.size()); - return hash_t(seed); + + const hash_t out(seed); + ::memset(seed.data(), 0, seed.size()); // clear memory + return out; }