util.random: Throw different error for EOL condition 0.11
authorKim Alvefur <zash@zash.se>
Tue, 21 May 2019 08:52:21 +0200
branch0.11
changeset 10020 af8c514e5cf7
parent 10019 8297408db58b
child 10021 994cccebb597
child 10030 1117138fa372
util.random: Throw different error for EOL condition
util/random.lua
--- 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