]> granicus.if.org Git - ejabberd/commitdiff
Fix randoms:uniform/1 return
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 18 Oct 2016 05:35:47 +0000 (08:35 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 18 Oct 2016 05:35:47 +0000 (08:35 +0300)
Make sure randoms:uniform/1 returns values from the same interval
as deprecated random:uniform/1

src/randoms.erl

index 75bc280a2805139c62fd995090a70bdf9b6eeaec..1353f48af4f68819d40a10ac8a467a76c357d358 100644 (file)
@@ -44,7 +44,7 @@ uniform() ->
     crypto:rand_uniform(0, ?THRESHOLD)/?THRESHOLD.
 
 uniform(N) ->
-    crypto:rand_uniform(0, N).
+    crypto:rand_uniform(1, N+1).
 
 -ifdef(STRONG_RAND_BYTES).
 bytes(N) ->