com php-src: Add global data for storing OpenSSL errors: ext/openssl/openssl.c ext/openssl/php_openssl.h
| From: | Jakub Zelenka | Date: | Thu, 07 Jan 2016 16:38:24 +0000 |
| Subject: | com php-src: Add global data for storing OpenSSL errors: ext/openssl/openssl.c ext/openssl/php_openssl.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92467@lists.php.net to get a copy of this message | ||
Commit: e00ba47d405190187faaf5b78669e873d26045d2
Author: Jakub Zelenka <bukka@php.net> Thu, 7 Jan 2016 16:38:24 +0000
Parents: da0eeacf1d6c69fb1c79fa08986edce3c166440b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e00ba47d405190187faaf5b78669e873d26045d2
Log:
Add global data for storing OpenSSL errors
Changed paths:
M ext/openssl/openssl.c
M ext/openssl/php_openssl.h
Diff:
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index a8ecbb2..c6b8e4b 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -86,6 +86,8 @@
#define HAVE_EVP_PKEY_EC 1
#endif
+ZEND_DECLARE_MODULE_GLOBALS(openssl)
+
/* FIXME: Use the openssl constants instead of
* enum. It is now impossible to match real values
* against php constants. Also sorry to break the
@@ -529,7 +531,11 @@ zend_module_entry openssl_module_entry = {
NULL,
PHP_MINFO(openssl),
PHP_OPENSSL_VERSION,
- STANDARD_MODULE_PROPERTIES
+ PHP_MODULE_GLOBALS(openssl),
+ PHP_GINIT(openssl),
+ NULL,
+ NULL,
+ STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
@@ -1297,6 +1303,17 @@ PHP_MINIT_FUNCTION(openssl)
}
/* }}} */
+/* {{{ PHP_GINIT_FUNCTION
+*/
+PHP_GINIT_FUNCTION(openssl)
+{
+#if defined(COMPILE_DL_OPENSSL) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
+ openssl_globals->errors = NULL;
+}
+/* }}} */
+
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(openssl)
@@ -1337,6 +1354,10 @@ PHP_MSHUTDOWN_FUNCTION(openssl)
/* reinstate the default tcp handler */
php_stream_xport_register("tcp", php_stream_generic_socket_factory);
+ if (OPENSSL_G(errors)) {
+ efree(OPENSSL_G(errors));
+ }
+
UNREGISTER_INI_ENTRIES();
return SUCCESS;
diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h
index 92e0124..a6f1635 100644
--- a/ext/openssl/php_openssl.h
+++ b/ext/openssl/php_openssl.h
@@ -46,11 +46,30 @@ extern zend_module_entry openssl_module_entry;
"DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:"
\
"AES256-GCM-SHA384:AES128:AES256:HIGH:!SSLv2:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!RC4:!ADH"
+#include <openssl/err.h>
+
+struct php_openssl_errors {
+ int buffer[ERR_NUM_ERRORS];
+ int top;
+ int bottom;
+};
+
+ZEND_BEGIN_MODULE_GLOBALS(openssl)
+ struct php_openssl_errors *errors;
+ZEND_END_MODULE_GLOBALS(openssl)
+
+#define OPENSSL_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(openssl, v)
+
+#if defined(ZTS) && defined(COMPILE_DL_OPENSSL)
+ZEND_TSRMLS_CACHE_EXTERN();
+#endif
+
php_stream_transport_factory_func php_openssl_ssl_socket_factory;
PHP_MINIT_FUNCTION(openssl);
PHP_MSHUTDOWN_FUNCTION(openssl);
PHP_MINFO_FUNCTION(openssl);
+PHP_GINIT_FUNCTION(openssl);
PHP_FUNCTION(openssl_pkey_get_private);
PHP_FUNCTION(openssl_pkey_get_public);