diff options
author | Kim Alvefur <zash@zash.se> | 2014-09-18 10:21:38 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-09-18 10:21:38 +0200 |
commit | ea8046b81b086c914d70faea3f2d208e6030fe37 (patch) | |
tree | c8d7c9d192aa84ad70ea4688421f963c9a6ca1be /util/random.lua | |
parent | ff30d91a0d32a4747b50f5bbd1ec5b2076073ec7 (diff) | |
download | prosody-ea8046b81b086c914d70faea3f2d208e6030fe37.tar.gz prosody-ea8046b81b086c914d70faea3f2d208e6030fe37.zip |
util.random: Ensure at least 4 bytes of previous random state is used when generating new randomness
Diffstat (limited to 'util/random.lua')
-rw-r--r-- | util/random.lua | 4 |
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 |