]> granicus.if.org Git - php/commitdiff
MFB: fix #40999 (mcrypt_create_iv() not using random seed)
authorAntony Dovgal <tony2001@php.net>
Sun, 8 Apr 2007 08:04:30 +0000 (08:04 +0000)
committerAntony Dovgal <tony2001@php.net>
Sun, 8 Apr 2007 08:04:30 +0000 (08:04 +0000)
ext/mcrypt/mcrypt.c

index 52b114e5665d7420875f25a51be7753d03bff060..261690ea5f0b5d6b099b52c8a6d8794df83e0aab 100644 (file)
@@ -35,6 +35,7 @@
 #include "php_ini.h"
 #include "php_globals.h"
 #include "ext/standard/info.h"
+#include "ext/standard/php_rand.h"
 
 static int le_mcrypt;
 
@@ -1039,8 +1040,7 @@ int php_mcrypt_iv(php_mcrypt_iv_source source, int size, char **iv_str, int *iv_
                case PHP_MCRYPT_IV_SOURCE_RAND:
                                *iv_len = size;
                                while (size) {
-                                       unsigned int ctx;
-                                       (*iv_str)[--size] = 255.0 * php_rand_r(&ctx) / RAND_MAX;
+                                       (*iv_str)[--size] = 255.0 * php_rand(TSRMLS_C) / RAND_MAX;
                                }
                        break;
        }