summaryrefslogtreecommitdiff
path: root/src/sp_execute.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_execute.c')
-rw-r--r--src/sp_execute.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c
index 7d62e88..014a049 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -28,17 +28,20 @@ ZEND_COLD static inline void terminate_if_writable(const char *filename) {
28 } 28 }
29} 29}
30 30
31static void check_inclusion_regexp(const char * const filename) { 31static void construct_include_handler(const char * const filename) {
32 if (SNUFFLEUPAGUS_G(config).config_regexp_inclusion->regexp_inclusion) { 32 if (SNUFFLEUPAGUS_G(config).config_disabled_constructs->construct_include) {
33 const sp_node_t* config = SNUFFLEUPAGUS_G(config).config_regexp_inclusion->regexp_inclusion; 33 const sp_node_t* config = SNUFFLEUPAGUS_G(config).config_disabled_constructs->construct_include;
34 if (!config || !config->data) { 34 if (!config || !config->data) {
35 return; 35 return;
36 } 36 }
37
37 while (config) { 38 while (config) {
38 pcre *config_node = (pcre*)(config->data); 39 sp_disabled_function *config_node = (sp_disabled_function*)(config->data);
39 if (false == is_regexp_matching(config_node, filename)) { 40 if (true == is_regexp_matching(config_node->regexp, filename)) {
40 sp_log_msg("include", SP_LOG_DROP, "Inclusion of a forbidden file (%s).", filename); 41 sp_log_disable("include", "inclusion path", filename, config_node);
41 sp_terminate(); 42 if (false == config_node->simulation) {
43 sp_terminate();
44 }
42 } 45 }
43 config = config->next; 46 config = config->next;
44 } 47 }
@@ -68,17 +71,22 @@ execute:
68 orig_execute_ex(execute_data); 71 orig_execute_ex(execute_data);
69} 72}
70 73
71static int sp_stream_open(const char *filename, 74static int sp_stream_open(const char *filename, zend_file_handle *handle) {
72 zend_file_handle *handle) { 75 zend_execute_data const * const data = EG(current_execute_data);
73 const zend_execute_data *data = EG(current_execute_data);
74 76
75 if ((NULL != data) && (NULL != data->opline) && 77 if ((NULL == data) || (NULL == data->opline)) {
76 (ZEND_INCLUDE_OR_EVAL == data->opline->opcode)) { 78 goto end;
77 if (true == SNUFFLEUPAGUS_G(config).config_readonly_exec->enable) {
78 terminate_if_writable(filename);
79 }
80 check_inclusion_regexp(filename);
81 } 79 }
80
81 switch(data->opline->opcode) {
82 case ZEND_INCLUDE_OR_EVAL:
83 if (true == SNUFFLEUPAGUS_G(config).config_readonly_exec->enable) {
84 terminate_if_writable(filename);
85 }
86 construct_include_handler(filename);
87 }
88
89end:
82 return orig_zend_stream_open(filename, handle); 90 return orig_zend_stream_open(filename, handle);
83} 91}
84 92