Skip to content

Commit

Permalink
auth/Crypto: assert(len <= 256) before calling getentropy()
Browse files Browse the repository at this point in the history
this assert() will be optimized out in Release mode.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit ccae47e)
  • Loading branch information
tchaikov authored and smithfarm committed Oct 31, 2019
1 parent 958e43a commit b1d4498
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/auth/Crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b1d4498

Please sign in to comment.