Software /
code /
prosody
Changeset
10016:af8c514e5cf7 0.11
util.random: Throw different error for EOL condition
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 21 May 2019 08:52:21 +0200 |
parents | 10015:8297408db58b |
children | 10017:994cccebb597 10026:1117138fa372 |
files | util/random.lua |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/util/random.lua Sat May 18 18:51:25 2019 +0200 +++ b/util/random.lua Tue May 21 08:52:21 2019 +0200 @@ -14,7 +14,11 @@ local function bytes(n) local data, err = urandom:read(n); if not data then - error("Unable to retrieve data from secure random number generator (/dev/urandom): "..tostring(err)); + if err then + error("Unable to retrieve data from secure random number generator (/dev/urandom): "..tostring(err)); + else + error("Secure random number generator (/dev/urandom) returned an end-of-file condition"); + end end return data; end