]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
auth/Crypto: assert(len <= 256) before calling getentropy() 31301/head
authorKefu Chai <kchai@redhat.com>
Tue, 24 Sep 2019 11:02:38 +0000 (19:02 +0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 31 Oct 2019 18:13:00 +0000 (19:13 +0100)
this assert() will be optimized out in Release mode.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit ccae47ea08a51f6a1d6c237cde75732dbb7b74df)

src/auth/Crypto.cc

index 49b32cab6f22ee9f07779f0d08d16a67b487b17b..67c6643bb315cbd628468e3cfc1072179e439ccd 100644 (file)
@@ -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) {