summaryrefslogtreecommitdiff
path: root/src/sp_execute.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2022-04-19 12:43:18 +0200
committerBen Fuhrmannek2022-04-19 12:43:18 +0200
commit1be112f371f860feab290cb333792c52e4e23c7c (patch)
tree66549320d2b7224caa4a30c4430f15664fe0e8f5 /src/sp_execute.c
parent5d1d7365d981f260023a193c5738413c4bfaa6bb (diff)
allow file:// prefix in include() wich readonly_exec mode
Diffstat (limited to 'src/sp_execute.c')
-rw-r--r--src/sp_execute.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c
index f1ed8d0..9cf44e1 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -17,9 +17,9 @@ ZEND_COLD static inline void terminate_if_writable(const char *filename) {
17 sp_log_request(config_ro_exec->dump, config_ro_exec->textual_representation); 17 sp_log_request(config_ro_exec->dump, config_ro_exec->textual_representation);
18 } 18 }
19 if (true == config_ro_exec->simulation) { 19 if (true == config_ro_exec->simulation) {
20 sp_log_simulation("readonly_exec", "Attempted execution of a writable file (%s).", filename); 20 sp_log_simulation("readonly_exec", "Attempted execution of a writable file (%s)", filename);
21 } else { 21 } else {
22 sp_log_drop("readonly_exec", "Attempted execution of a writable file (%s).", filename); 22 sp_log_drop("readonly_exec", "Attempted execution of a writable file (%s)", filename);
23 } 23 }
24 } else { 24 } else {
25 if (EACCES != errno) { 25 if (EACCES != errno) {
@@ -224,13 +224,18 @@ static inline void sp_stream_open_checks(zend_string *zend_filename, zend_file_h
224 return; 224 return;
225 } 225 }
226 226
227 // zend_string *zend_filename = zend_string_init(filename, strlen(filename), 0);
228 const HashTable *disabled_functions_hooked = SPCFG(disabled_functions_hooked); 227 const HashTable *disabled_functions_hooked = SPCFG(disabled_functions_hooked);
229 228
230 switch (data->opline->opcode) { 229 switch (data->opline->opcode) {
231 case ZEND_INCLUDE_OR_EVAL: 230 case ZEND_INCLUDE_OR_EVAL:
232 if (SPCFG(readonly_exec).enable) { 231 if (SPCFG(readonly_exec).enable) {
233 terminate_if_writable(ZSTR_VAL(zend_filename)); 232 char *fn = ZSTR_VAL(zend_filename);
233 if (ZSTR_LEN(zend_filename) >= strlen("file://") && memcmp(fn, "file://", strlen("file://")) == 0) {
234 fn += strlen("file://");
235 } else if (!php_memnstr(ZSTR_VAL(zend_filename), "://", strlen("://"), ZSTR_VAL(zend_filename) + ZSTR_LEN(zend_filename))) {
236 // ignore stream wrappers other than file:// for now
237 terminate_if_writable(fn);
238 }
234 } 239 }
235 switch (data->opline->extended_value) { 240 switch (data->opline->extended_value) {
236 case ZEND_INCLUDE: 241 case ZEND_INCLUDE: