summaryrefslogtreecommitdiff
path: root/src/sp_session.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-09-23 12:23:40 +0200
committerBen Fuhrmannek2021-09-23 12:23:40 +0200
commit54c352c1b5aa08b187dd1e52e544709cad2b0fee (patch)
treed15bf0f484c6baa1f2718e625e0d49f6fb488507 /src/sp_session.c
parent887e1c9d44fbcf5f23a928269034593b8521aaba (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_session.c')
-rw-r--r--src/sp_session.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sp_session.c b/src/sp_session.c
index 64233d1..b54849e 100644
--- a/src/sp_session.c
+++ b/src/sp_session.c
@@ -25,7 +25,7 @@ static int (*previous_sessionRINIT)(INIT_FUNC_ARGS) = NULL;
25static ZEND_INI_MH((*old_OnUpdateSaveHandler)) = NULL; 25static ZEND_INI_MH((*old_OnUpdateSaveHandler)) = NULL;
26 26
27static void check_sid_length(zend_string *sid) { 27static void check_sid_length(zend_string *sid) {
28 const sp_config_session *cfg = SNUFFLEUPAGUS_G(config).config_session; 28 const sp_config_session *cfg = &(SPCFG(session));
29 29
30 if (sid) { 30 if (sid) {
31 if (cfg->sid_min_length && ZSTR_LEN(sid) < cfg->sid_min_length) { 31 if (cfg->sid_min_length && ZSTR_LEN(sid) < cfg->sid_min_length) {
@@ -38,7 +38,7 @@ static void check_sid_length(zend_string *sid) {
38} 38}
39 39
40static int sp_hook_s_read(PS_READ_ARGS) { 40static int sp_hook_s_read(PS_READ_ARGS) {
41 const sp_config_session *cfg = SNUFFLEUPAGUS_G(config).config_session; 41 const sp_config_session *cfg = &(SPCFG(session));
42 check_sid_length(key); 42 check_sid_length(key);
43 43
44 int r = old_s_read(mod_data, key, val, maxlifetime); 44 int r = old_s_read(mod_data, key, val, maxlifetime);
@@ -65,7 +65,7 @@ static int sp_hook_s_read(PS_READ_ARGS) {
65} 65}
66 66
67static int sp_hook_s_write(PS_WRITE_ARGS) { 67static int sp_hook_s_write(PS_WRITE_ARGS) {
68 const sp_config_session *cfg = SNUFFLEUPAGUS_G(config).config_session; 68 const sp_config_session *cfg = &(SPCFG(session));
69 check_sid_length(key); 69 check_sid_length(key);
70 70
71 if (ZSTR_LEN(val) > 0 && cfg->encrypt) { 71 if (ZSTR_LEN(val) > 0 && cfg->encrypt) {