Software /
code /
prosody
Diff
util/random.lua @ 6421:c3011ab945b8
util.random: Ensure at least 4 bytes of previous random state is used when generating new randomness
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 18 Sep 2014 10:21:38 +0200 |
parent | 6420:0c070e30a7db |
child | 7050:ae044691de0f |
line wrap: on
line diff
--- a/util/random.lua Thu Sep 18 10:16:59 2014 +0200 +++ b/util/random.lua Thu Sep 18 10:21:38 2014 +0200 @@ -31,8 +31,8 @@ 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