aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2014-09-18 10:21:38 +0200
committerKim Alvefur <zash@zash.se>2014-09-18 10:21:38 +0200
commitea8046b81b086c914d70faea3f2d208e6030fe37 (patch)
treec8d7c9d192aa84ad70ea4688421f963c9a6ca1be
parentff30d91a0d32a4747b50f5bbd1ec5b2076073ec7 (diff)
downloadprosody-ea8046b81b086c914d70faea3f2d208e6030fe37.tar.gz
prosody-ea8046b81b086c914d70faea3f2d208e6030fe37.zip
util.random: Ensure at least 4 bytes of previous random state is used when generating new randomness
-rw-r--r--util/random.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/random.lua b/util/random.lua
index 328bdb00..5938a94f 100644
--- a/util/random.lua
+++ b/util/random.lua
@@ -31,8 +31,8 @@ local function seed(x)
end
local function bytes(n)
- if #buffer < n then seed(uniq_time()); end
- local r = buffer:sub(0, n);
+ if #buffer < n+4 then seed(uniq_time()); end
+ local r = buffer:sub(1, n);
buffer = buffer:sub(n+1);
return r;
end