From 5d5951f2473f5b0b596540631920fda2ac657160 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sun, 10 Jul 2011 14:36:32 +0000 Subject: [PATCH] - fix bug #55169, mcrypt_create_iv always fails to gather sufficient random data --- NEWS | 2 ++ win32/winutil.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index fdfb050a5b..154d3a092c 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ PHP NEWS - MCrypt . Change E_ERROR to E_WARNING in mcrypt_create_iv when not enough data has been fetched (Windows). (Pierre) + . Fixed bug #55169 (mcrypt_create_iv always fails to gather sufficient random + data on Windows). (Pierre) - PDO DBlib: . Fixed bug #54329 (MSSql extension memory leak). diff --git a/win32/winutil.c b/win32/winutil.c index adc5d1b66b..c6ec942969 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -87,7 +87,7 @@ PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) { /* {{{ #endif if (has_crypto_ctx == 0) { - if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET)) { + if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) { /* Could mean that the key container does not exist, let try again by asking for a new one */ if (GetLastError() == NTE_BAD_KEYSET) { @@ -97,6 +97,8 @@ PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) { /* {{{ has_crypto_ctx = 0; } } + } else { + has_crypto_ctx = 1; } } -- 2.40.0