Changeset

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
parents 6420:0c070e30a7db
children 6422:6d4d87a89026
files util/random.lua
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
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