From b1d44987109e792521be0dce7f0af12445814d45 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 24 Sep 2019 19:02:38 +0800 Subject: [PATCH] auth/Crypto: assert(len <= 256) before calling getentropy() this assert() will be optimized out in Release mode. Signed-off-by: Kefu Chai (cherry picked from commit ccae47ea08a51f6a1d6c237cde75732dbb7b74df) --- src/auth/Crypto.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/auth/Crypto.cc b/src/auth/Crypto.cc index 49b32cab6f2..67c6643bb31 100644 --- a/src/auth/Crypto.cc +++ b/src/auth/Crypto.cc @@ -70,6 +70,8 @@ void CryptoRandom::get_bytes(char *buf, int len) if (unlikely(fd >= 0)) { ret = safe_read_exact(fd, buf, len); } else { + // getentropy() reads up to 256 bytes + assert(len <= 256); ret = TEMP_FAILURE_RETRY(::getentropy(buf, len)); } if (ret < 0) { -- 2.47.3