Skip to content

Commit

Permalink
- fix bug #55169, mcrypt_create_iv always fails to gather sufficient …
Browse files Browse the repository at this point in the history
…random data
  • Loading branch information
pierrejoye committed Jul 10, 2011
1 parent 8ec6ada commit 5d5951f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -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).
Expand Down
4 changes: 3 additions & 1 deletion win32/winutil.c
Expand Up @@ -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) {
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 5d5951f

Please sign in to comment.