# HG changeset patch # User Kim Alvefur # Date 1411028498 -7200 # Node ID c3011ab945b8a95719e8b5bf8685990d35ffac57 # Parent 0c070e30a7db2045606c086fc913517f8ba81a0e util.random: Ensure at least 4 bytes of previous random state is used when generating new randomness diff -r 0c070e30a7db -r c3011ab945b8 util/random.lua --- 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