File 1002-compile-Eliminate-use-of-the-obsolete-random-module.patch of Package erlang

From dee396ffd32dcd68c47cab983c75ba32f921b9db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 4 Dec 2015 12:10:42 +0100
Subject: [PATCH 01/15] compile: Eliminate use of the obsolete 'random' module

The 'random' module is used to pad the end of a block with random
bytes. The appropriate function to use in this case
crypto:rand_bytes/1.
---
 lib/compiler/src/compile.erl | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index a2a23a2..b61c104 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -1306,21 +1306,12 @@ generate_key(String) when is_list(String) ->
 encrypt({des3_cbc=Type,Key,IVec,BlockSize}, Bin0) ->
     Bin1 = case byte_size(Bin0) rem BlockSize of
 	       0 -> Bin0;
-	       N -> list_to_binary([Bin0,random_bytes(BlockSize-N)])
+	       N -> list_to_binary([Bin0,crypto:rand_bytes(BlockSize-N)])
 	   end,
     Bin = crypto:block_encrypt(Type, Key, IVec, Bin1),
     TypeString = atom_to_list(Type),
     list_to_binary([0,length(TypeString),TypeString,Bin]).
 
-random_bytes(N) ->
-    _ = random:seed(erlang:time_offset(),
-		    erlang:monotonic_time(),
-		    erlang:unique_integer()),
-    random_bytes_1(N, []).
-
-random_bytes_1(0, Acc) -> Acc;
-random_bytes_1(N, Acc) -> random_bytes_1(N-1, [random:uniform(255)|Acc]).
-
 save_core_code(St) ->
     {ok,St#compile{core_code=cerl:from_records(St#compile.code)}}.
 
-- 
2.1.4

openSUSE Build Service is sponsored by