From 1159322c355dcc7b29e0a98224a08f1e14df2207 Mon Sep 17 00:00:00 2001 From: Armin Preiml Date: Thu, 11 Jul 2019 15:32:51 +0200 Subject: [PATCH] make sure we got enough random bytes --- init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 0ba60e4..d4efe1f 100644 --- a/init.lua +++ b/init.lua @@ -36,7 +36,11 @@ end -- Efficient function to get a random string function random_string() - local random_bytes = io.open("/dev/urandom"):read(64); + local length = 64 + local random_bytes = io.open("/dev/urandom"):read(length); + if string.len(random_bytes) ~= length then + error("Not enough random bytes read") + end return tohex(random_bytes); end