File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 24
24
25
25
#include "php.h"
26
26
#include "php_rand.h"
27
+ #include "php_random.h"
27
28
#include "php_mt_rand.h"
28
29
29
30
/* MT RAND FUNCTIONS */
@@ -161,7 +162,11 @@ PHPAPI uint32_t php_mt_rand(void)
161
162
register uint32_t s1 ;
162
163
163
164
if (UNEXPECTED (!BG (mt_rand_is_seeded ))) {
164
- php_mt_srand (GENERATE_SEED ());
165
+ zend_long bytes ;
166
+ if (php_random_bytes_silent (& bytes , sizeof (zend_long )) == FAILURE ) {
167
+ bytes = GENERATE_SEED ();
168
+ }
169
+ php_mt_srand (bytes );
165
170
}
166
171
167
172
if (BG (left ) == 0 ) {
@@ -189,8 +194,11 @@ PHP_FUNCTION(mt_srand)
189
194
Z_PARAM_LONG (mode )
190
195
ZEND_PARSE_PARAMETERS_END ();
191
196
192
- if (ZEND_NUM_ARGS () == 0 )
193
- seed = GENERATE_SEED ();
197
+ if (ZEND_NUM_ARGS () == 0 ) {
198
+ if (php_random_bytes_silent (& seed , sizeof (zend_long )) == FAILURE ) {
199
+ seed = GENERATE_SEED ();
200
+ }
201
+ }
194
202
195
203
switch (mode ) {
196
204
case MT_RAND_PHP :
You can’t perform that action at this time.
0 commit comments