diff options
| author | Ben Fuhrmannek | 2021-09-23 12:23:40 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-09-23 12:23:40 +0200 |
| commit | 54c352c1b5aa08b187dd1e52e544709cad2b0fee (patch) | |
| tree | d15bf0f484c6baa1f2718e625e0d49f6fb488507 /src/php_snuffleupagus.h | |
| parent | 887e1c9d44fbcf5f23a928269034593b8521aaba (diff) | |
config is stack allocated now + some code improvements (see details)
* for easier memory manegement, the entire sp_config struct was merged into snuffleupagus_globals and allocated on stack where possible
* SNUFFLEUPAGUS_G() can be written as SPG(), which is faster to type and easier to read
* execution_depth is re-initialized to 0 for each request
* function calls with inline string and length parameters consistently use ZEND_STRL instead of sizeof()-1
* execution is actually hooked if recursion protection is enabled
* some line breaks were removed to make the code more readable
Diffstat (limited to 'src/php_snuffleupagus.h')
| -rw-r--r-- | src/php_snuffleupagus.h | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h index bcb613c..308031b 100644 --- a/src/php_snuffleupagus.h +++ b/src/php_snuffleupagus.h | |||
| @@ -106,11 +106,44 @@ extern zend_module_entry snuffleupagus_module_entry; | |||
| 106 | #endif | 106 | #endif |
| 107 | 107 | ||
| 108 | ZEND_BEGIN_MODULE_GLOBALS(snuffleupagus) | 108 | ZEND_BEGIN_MODULE_GLOBALS(snuffleupagus) |
| 109 | size_t in_eval; | 109 | // sp_config config; |
| 110 | sp_config config; | 110 | // --- snuffleupagus config |
| 111 | sp_config_random config_random; | ||
| 112 | sp_config_sloppy config_sloppy; | ||
| 113 | sp_config_unserialize config_unserialize; | ||
| 114 | sp_config_readonly_exec config_readonly_exec; | ||
| 115 | sp_config_upload_validation config_upload_validation; | ||
| 116 | sp_config_cookie config_cookie; | ||
| 117 | sp_config_auto_cookie_secure config_auto_cookie_secure; | ||
| 118 | sp_config_global_strict config_global_strict; | ||
| 119 | sp_config_disable_xxe config_disable_xxe; | ||
| 120 | sp_config_eval config_eval; | ||
| 121 | sp_config_wrapper config_wrapper; | ||
| 122 | sp_config_session config_session; | ||
| 123 | sp_config_ini config_ini; | ||
| 124 | char config_log_media; | ||
| 125 | u_long config_max_execution_depth; | ||
| 126 | bool config_server_encode; | ||
| 127 | bool config_server_strip; | ||
| 128 | zend_string *config_encryption_key; | ||
| 129 | zend_string *config_cookies_env_var; | ||
| 130 | |||
| 131 | HashTable *config_disabled_functions; | ||
| 132 | HashTable *config_disabled_functions_hooked; | ||
| 133 | HashTable *config_disabled_functions_ret; | ||
| 134 | HashTable *config_disabled_functions_ret_hooked; | ||
| 135 | sp_config_disabled_functions config_disabled_functions_reg; | ||
| 136 | sp_config_disabled_functions config_disabled_functions_reg_ret; | ||
| 137 | |||
| 138 | bool hook_execute; | ||
| 139 | |||
| 140 | // --- ini options | ||
| 141 | bool allow_broken_configuration; | ||
| 142 | |||
| 143 | // --- runtime/state variables | ||
| 111 | int is_config_valid; // 1 = valid, 0 = invalid, -1 = none | 144 | int is_config_valid; // 1 = valid, 0 = invalid, -1 = none |
| 145 | size_t in_eval; | ||
| 112 | u_long execution_depth; | 146 | u_long execution_depth; |
| 113 | bool allow_broken_configuration; | ||
| 114 | HashTable *disabled_functions_hook; | 147 | HashTable *disabled_functions_hook; |
| 115 | HashTable *sp_internal_functions_hook; | 148 | HashTable *sp_internal_functions_hook; |
| 116 | HashTable *sp_eval_blacklist_functions_hook; | 149 | HashTable *sp_eval_blacklist_functions_hook; |
| @@ -118,6 +151,8 @@ ZEND_END_MODULE_GLOBALS(snuffleupagus) | |||
| 118 | 151 | ||
| 119 | ZEND_EXTERN_MODULE_GLOBALS(snuffleupagus) | 152 | ZEND_EXTERN_MODULE_GLOBALS(snuffleupagus) |
| 120 | #define SNUFFLEUPAGUS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(snuffleupagus, v) | 153 | #define SNUFFLEUPAGUS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(snuffleupagus, v) |
| 154 | #define SPG(v) SNUFFLEUPAGUS_G(v) | ||
| 155 | #define SPCFG(v) SPG(config_##v) | ||
| 121 | 156 | ||
| 122 | #if defined(ZTS) && defined(COMPILE_DL_SNUFFLEUPAGUS) | 157 | #if defined(ZTS) && defined(COMPILE_DL_SNUFFLEUPAGUS) |
| 123 | ZEND_TSRMLS_CACHE_EXTERN() | 158 | ZEND_TSRMLS_CACHE_EXTERN() |
