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/sp_cookie_encryption.c | |
| 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/sp_cookie_encryption.c')
| -rw-r--r-- | src/sp_cookie_encryption.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c index 7bcedd2..b2cff66 100644 --- a/src/sp_cookie_encryption.c +++ b/src/sp_cookie_encryption.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | static inline const sp_cookie *sp_lookup_cookie_config(const zend_string *key) { | 3 | static inline const sp_cookie *sp_lookup_cookie_config(const zend_string *key) { |
| 4 | const sp_list_node *it = SNUFFLEUPAGUS_G(config).config_cookie->cookies; | 4 | const sp_list_node *it = SPCFG(cookie).cookies; |
| 5 | 5 | ||
| 6 | while (it) { | 6 | while (it) { |
| 7 | const sp_cookie *config = it->data; | 7 | const sp_cookie *config = it->data; |
| @@ -133,11 +133,11 @@ PHP_FUNCTION(sp_setcookie) { | |||
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /* If the request was issued over HTTPS, the cookie should be "secure" */ | 135 | /* If the request was issued over HTTPS, the cookie should be "secure" */ |
| 136 | if (SNUFFLEUPAGUS_G(config).config_auto_cookie_secure) { | 136 | if (SPCFG(auto_cookie_secure).enable) { |
| 137 | const zval server_vars = PG(http_globals)[TRACK_VARS_SERVER]; | 137 | const zval server_vars = PG(http_globals)[TRACK_VARS_SERVER]; |
| 138 | if (Z_TYPE(server_vars) == IS_ARRAY) { | 138 | if (Z_TYPE(server_vars) == IS_ARRAY) { |
| 139 | const zval *is_https = | 139 | const zval *is_https = |
| 140 | zend_hash_str_find(Z_ARRVAL(server_vars), "HTTPS", strlen("HTTPS")); | 140 | zend_hash_str_find(Z_ARRVAL(server_vars), ZEND_STRL("HTTPS")); |
| 141 | if (NULL != is_https) { | 141 | if (NULL != is_https) { |
| 142 | secure = 1; | 142 | secure = 1; |
| 143 | } | 143 | } |
