diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-08-19 10:22:38 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-08-19 10:22:38 +0200 |
commit | f452a2b3e4e4279b27594a8ddb66525442d59227 (patch) | |
tree | d05cb62c5515ada33076d3cc3e49b664733a478c /win32 | |
parent | 038ba12e8724d537040e88ec794354b0c063f0a6 (diff) | |
download | php-f452a2b3e4e4279b27594a8ddb66525442d59227.tar.gz |
Imported Upstream version 5.3.7upstream/5.3.7
Diffstat (limited to 'win32')
-rw-r--r-- | win32/build/config.w32 | 4 | ||||
-rw-r--r-- | win32/build/libs_version.txt | 2 | ||||
-rw-r--r-- | win32/install.txt | 2 | ||||
-rw-r--r-- | win32/winutil.c | 70 | ||||
-rw-r--r-- | win32/winutil.h | 8 |
5 files changed, 71 insertions, 15 deletions
diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 318dd96d9..ead7dfb52 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -1,5 +1,5 @@ // vim:ft=javascript -// $Id: config.w32 308863 2011-03-02 18:35:10Z moriyoshi $ +// $Id: config.w32 309779 2011-03-28 10:55:34Z pajoye $ // "Master" config file; think of it as a configure.in // equivalent. @@ -414,7 +414,7 @@ if (PHP_SECURITY_FLAGS == "yes") { } ARG_ENABLE("static-analyze", "Enable the VC compiler static analyze", "no"); -if (PHP_STATIC_ANALYZE == "yes" && PHP_SNAPSHOT_BUILD == "no") { +if (PHP_STATIC_ANALYZE == "yes") { ADD_FLAG("CFLAGS", " /analyze "); ADD_FLAG("CFLAGS", " /wd6308 "); } diff --git a/win32/build/libs_version.txt b/win32/build/libs_version.txt new file mode 100644 index 000000000..7f808fb52 --- /dev/null +++ b/win32/build/libs_version.txt @@ -0,0 +1,2 @@ +libcurl-7.21.7
+libpng-1.2.46
diff --git a/win32/install.txt b/win32/install.txt index c1fc9c20a..12d109b51 100644 --- a/win32/install.txt +++ b/win32/install.txt @@ -1427,7 +1427,7 @@ The configuration file core directives is available in the appendix. Probably not all PHP directives are documented in the manual though. For a complete list of directives available in your PHP version, please read your well - commented php.ini file. Alternatively, you may find the the latest + commented php.ini file. Alternatively, you may find the latest php.ini from SVN helpful too. Example 5-1. php.ini example diff --git a/win32/winutil.c b/win32/winutil.c index 4e8a68283..f59de316c 100644 --- a/win32/winutil.c +++ b/win32/winutil.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: winutil.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: winutil.c 313175 2011-07-12 11:46:41Z pajoye $ */ #include "php.h" #include <wincrypt.h> @@ -49,26 +49,72 @@ int php_win32_check_trailing_space(const char * path, const int path_len) { } } +HCRYPTPROV hCryptProv; +unsigned int has_crypto_ctx = 0; + +#ifdef ZTS +MUTEX_T php_lock_win32_cryptoctx; +void php_win32_init_rng_lock() +{ + php_lock_win32_cryptoctx = tsrm_mutex_alloc(); +} + +void php_win32_free_rng_lock() +{ + tsrm_mutex_lock(php_lock_win32_cryptoctx); + CryptReleaseContext(hCryptProv, 0); + has_crypto_ctx = 0; + tsrm_mutex_unlock(php_lock_win32_cryptoctx); + tsrm_mutex_free(php_lock_win32_cryptoctx); + +} +#else +#define php_win32_init_rng_lock(); +#define php_win32_free_rng_lock(); +#endif + + + PHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) { /* {{{ */ - HCRYPTPROV hCryptProv; - int has_context = 0; + + unsigned int has_contextg = 0; + BOOL ret; size_t i = 0; - 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) { - if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { - has_context = 1; - } else { - return FAILURE; +#ifdef ZTS + tsrm_mutex_lock(php_lock_win32_cryptoctx); +#endif + + if (has_crypto_ctx == 0) { + /* CRYPT_VERIFYCONTEXT > only hashing&co-like use, no need to acces prv keys */ + if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET|CRYPT_VERIFYCONTEXT )) { + /* Could mean that the key container does not exist, let try + again by asking for a new one. If it fails here, it surely means that the user running + this process does not have the permission(s) to use this container. + */ + if (GetLastError() == NTE_BAD_KEYSET) { + if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET | CRYPT_MACHINE_KEYSET | CRYPT_VERIFYCONTEXT )) { + has_crypto_ctx = 1; + } else { + has_crypto_ctx = 0; + } } + } else { + has_crypto_ctx = 1; } } +#ifdef ZTS + tsrm_mutex_unlock(php_lock_win32_cryptoctx); +#endif + + if (has_crypto_ctx == 0) { + return FAILURE; + } + ret = CryptGenRandom(hCryptProv, size, buf); - CryptReleaseContext(hCryptProv, 0); + if (ret) { return SUCCESS; } else { diff --git a/win32/winutil.h b/win32/winutil.h index ac1d15d57..a01f1fd6f 100644 --- a/win32/winutil.h +++ b/win32/winutil.h @@ -21,3 +21,11 @@ PHPAPI char *php_win_err(int error); #define php_win_err() php_win_err(GetLastError()) int php_win32_check_trailing_space(const char * path, const int path_len); PHPAPI php_win32_get_random_bytes(unsigned char *buf, size_t size); + +#ifdef ZTS +void php_win32_init_rng_lock(); +void php_win32_free_rng_lock(); +#else +#define php_win32_init_rng_lock(); +#define php_win32_free_rng_lock(); +#endif |