diff options
Diffstat (limited to 'src/sp_execute.c')
| -rw-r--r-- | src/sp_execute.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c index 2b8bb2e..cc401aa 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) { |
| @@ -226,13 +226,18 @@ static inline void sp_stream_open_checks(zend_string *zend_filename, zend_file_h | |||
| 226 | return; | 226 | return; |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | // zend_string *zend_filename = zend_string_init(filename, strlen(filename), 0); | ||
| 230 | const HashTable *disabled_functions_hooked = SPCFG(disabled_functions_hooked); | 229 | const HashTable *disabled_functions_hooked = SPCFG(disabled_functions_hooked); |
| 231 | 230 | ||
| 232 | switch (data->opline->opcode) { | 231 | switch (data->opline->opcode) { |
| 233 | case ZEND_INCLUDE_OR_EVAL: | 232 | case ZEND_INCLUDE_OR_EVAL: |
| 234 | if (SPCFG(readonly_exec).enable) { | 233 | if (SPCFG(readonly_exec).enable) { |
| 235 | terminate_if_writable(ZSTR_VAL(zend_filename)); | 234 | char *fn = ZSTR_VAL(zend_filename); |
| 235 | if (ZSTR_LEN(zend_filename) >= strlen("file://") && memcmp(fn, "file://", strlen("file://")) == 0) { | ||
| 236 | fn += strlen("file://"); | ||
| 237 | } else if (!php_memnstr(ZSTR_VAL(zend_filename), "://", strlen("://"), ZSTR_VAL(zend_filename) + ZSTR_LEN(zend_filename))) { | ||
| 238 | // ignore stream wrappers other than file:// for now | ||
| 239 | terminate_if_writable(fn); | ||
| 240 | } | ||
| 236 | } | 241 | } |
| 237 | switch (data->opline->extended_value) { | 242 | switch (data->opline->extended_value) { |
| 238 | case ZEND_INCLUDE: | 243 | case ZEND_INCLUDE: |
