From: Kefu Chai Date: Tue, 24 Sep 2019 11:02:38 +0000 (+0800) Subject: auth/Crypto: assert(len <= 256) before calling getentropy() X-Git-Tag: v14.2.8~28^2~2^2~16^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b1d44987109e792521be0dce7f0af12445814d45;p=ceph.git 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) --- 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) {