summaryrefslogtreecommitdiff
path: root/src/sp_session.c
diff options
context:
space:
mode:
authorkkadosh2018-06-28 21:43:40 +0000
committerjvoisin2018-06-28 21:43:40 +0000
commitca3be84076521c4bb053511775c94c0b195aeac8 (patch)
tree3026bd494850086795a67d18f56264abbe4cc11c /src/sp_session.c
parent7832438b7abedf567ce6376f99949f419abcdff1 (diff)
Better handling of filters for builtins
Diffstat (limited to 'src/sp_session.c')
-rw-r--r--src/sp_session.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/sp_session.c b/src/sp_session.c
index 4085007..ce852ad 100644
--- a/src/sp_session.c
+++ b/src/sp_session.c
@@ -21,7 +21,6 @@ static int (*old_s_write)(PS_WRITE_ARGS);
21static int (*previous_sessionRINIT)(INIT_FUNC_ARGS) = NULL; 21static int (*previous_sessionRINIT)(INIT_FUNC_ARGS) = NULL;
22static ZEND_INI_MH((*old_OnUpdateSaveHandler)) = NULL; 22static ZEND_INI_MH((*old_OnUpdateSaveHandler)) = NULL;
23 23
24
25static int sp_hook_s_read(PS_READ_ARGS) { 24static int sp_hook_s_read(PS_READ_ARGS) {
26 int r = old_s_read(mod_data, key, val, maxlifetime); 25 int r = old_s_read(mod_data, key, val, maxlifetime);
27 if (r == SUCCESS && SNUFFLEUPAGUS_G(config).config_session->encrypt && 26 if (r == SUCCESS && SNUFFLEUPAGUS_G(config).config_session->encrypt &&
@@ -31,8 +30,7 @@ static int sp_hook_s_read(PS_READ_ARGS) {
31 ZVAL_PSTRINGL(&val_zval, ZSTR_VAL(*val), ZSTR_LEN(*val)); 30 ZVAL_PSTRINGL(&val_zval, ZSTR_VAL(*val), ZSTR_LEN(*val));
32 31
33 int ret = decrypt_zval( 32 int ret = decrypt_zval(
34 &val_zval, SNUFFLEUPAGUS_G(config).config_session->simulation, 33 &val_zval, SNUFFLEUPAGUS_G(config).config_session->simulation, NULL);
35 NULL);
36 if (0 != ret) { 34 if (0 != ret) {
37 if (SNUFFLEUPAGUS_G(config).config_session->simulation) { 35 if (SNUFFLEUPAGUS_G(config).config_session->simulation) {
38 return ret; 36 return ret;
@@ -51,10 +49,8 @@ static int sp_hook_s_read(PS_READ_ARGS) {
51 return r; 49 return r;
52} 50}
53 51
54
55static int sp_hook_s_write(PS_WRITE_ARGS) { 52static int sp_hook_s_write(PS_WRITE_ARGS) {
56 if (ZSTR_LEN(val) > 0 && 53 if (ZSTR_LEN(val) > 0 && SNUFFLEUPAGUS_G(config).config_session->encrypt) {
57 SNUFFLEUPAGUS_G(config).config_session->encrypt) {
58 zend_string *new_val = encrypt_zval(ZSTR_VAL(val), ZSTR_LEN(val)); 54 zend_string *new_val = encrypt_zval(ZSTR_VAL(val), ZSTR_LEN(val));
59 return old_s_write(mod_data, key, new_val, maxlifetime); 55 return old_s_write(mod_data, key, new_val, maxlifetime);
60 } 56 }
@@ -92,11 +88,9 @@ static void sp_hook_session_module() {
92 88
93static PHP_INI_MH(sp_OnUpdateSaveHandler) { 89static PHP_INI_MH(sp_OnUpdateSaveHandler) {
94 if (stage == PHP_INI_STAGE_RUNTIME && 90 if (stage == PHP_INI_STAGE_RUNTIME &&
95 SESSION_G(session_status) == php_session_none && 91 SESSION_G(session_status) == php_session_none && s_original_mod &&
96 s_original_mod &&
97 zend_string_equals_literal(new_value, "user") == 0 && 92 zend_string_equals_literal(new_value, "user") == 0 &&
98 strcmp(((ps_module *)s_original_mod)->s_name, "user") == 93 strcmp(((ps_module *)s_original_mod)->s_name, "user") == 0) {
99 0) {
100 return SUCCESS; 94 return SUCCESS;
101 } 95 }
102 96