]> granicus.if.org Git - php/commitdiff
- re apply the rng change specific to windows, long term it should be a std function...
authorPierre Joye <pajoye@php.net>
Tue, 19 Jul 2011 23:01:41 +0000 (23:01 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 19 Jul 2011 23:01:41 +0000 (23:01 +0000)
ext/openssl/openssl.c

index f8266a381c241b3f3c3387ccea85a95f0c905283..b41d04c3bb47361c5d1565e126cdce9e12bc44ef 100644 (file)
@@ -4930,10 +4930,19 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
 
        buffer = emalloc(buffer_length + 1);
 
+#ifdef PHP_WIN32
+       strong_result = 1;
+       /* random/urandom equivalent on Windows */
+       if (php_win32_get_random_bytes(buffer, (size_t) buffer_length) == FAILURE){
+               efree(buffer);
+               RETURN_FALSE;
+       }
+#else
        if ((strong_result = RAND_pseudo_bytes(buffer, buffer_length)) < 0) {
                efree(buffer);
                RETURN_FALSE;
        }
+#endif
 
        buffer[buffer_length] = 0;
        RETVAL_STRINGL((char *)buffer, buffer_length, 0);