Software /
code /
prosody
Diff
util/random.lua @ 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 |
parent | 10015:8297408db58b |
child | 12446:e54b8a5e35ad |
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