summaryrefslogtreecommitdiff
path: root/src/sp_wrapper.c
diff options
context:
space:
mode:
authorjvoisin2022-03-20 18:20:45 +0100
committerjvoisin2022-03-20 18:20:45 +0100
commit81dd7f2ef07af306fe83d7755cbac4529aa9fc8d (patch)
tree32cc44c6231b30db5ac7b15699297863460784aa /src/sp_wrapper.c
parent83b01942dfc80474cc05e09aeef4b44307a7120b (diff)
parentc38df1077a6c1dfbca1baca049214d053e2e7684 (diff)
Merge remote-tracking branch 'sektioneins/master'
Diffstat (limited to 'src/sp_wrapper.c')
-rw-r--r--src/sp_wrapper.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/sp_wrapper.c b/src/sp_wrapper.c
index 7610114..9eb5cbc 100644
--- a/src/sp_wrapper.c
+++ b/src/sp_wrapper.c
@@ -1,7 +1,7 @@
1#include "php_snuffleupagus.h" 1#include "php_snuffleupagus.h"
2 2
3static bool wrapper_is_whitelisted(const zend_string *const zs) { 3static bool wrapper_is_whitelisted(const zend_string *const zs) {
4 const sp_list_node *list = SNUFFLEUPAGUS_G(config).config_wrapper->whitelist; 4 const sp_list_node *list = SPCFG(wrapper).whitelist;
5 5
6 if (!zs) { 6 if (!zs) {
7 return false; // LCOV_EXCL_LINE 7 return false; // LCOV_EXCL_LINE
@@ -38,24 +38,19 @@ void sp_disable_wrapper() {
38 38
39 zend_hash_destroy(orig_complete); 39 zend_hash_destroy(orig_complete);
40 pefree(orig_complete, 1); 40 pefree(orig_complete, 1);
41 SNUFFLEUPAGUS_G(config).config_wrapper->num_wrapper = 41 SPCFG(wrapper).num_wrapper = zend_hash_num_elements(orig);
42 zend_hash_num_elements(orig);
43} 42}
44 43
45PHP_FUNCTION(sp_stream_wrapper_register) { 44PHP_FUNCTION(sp_stream_wrapper_register) {
46 zif_handler orig_handler; 45 zif_handler orig_handler;
47 zend_string *protocol_name = NULL; 46 zend_string *protocol_name = NULL;
47 zval *params = NULL;
48 uint32_t param_count = 0;
48 49
49 // LCOV_EXCL_BR_START 50 zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "S*", &protocol_name, &params, &param_count);
50 ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_QUIET, 2, EX_NUM_ARGS()); 51 // ignore proper arguments here and just let the original handler deal with it
51 Z_PARAM_STR(protocol_name); 52 if (!protocol_name || wrapper_is_whitelisted(protocol_name)) {
52 ZEND_PARSE_PARAMETERS_END_EX((void)0); 53 orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("stream_wrapper_register"));
53 // LCOV_EXCL_BR_END
54
55 if (wrapper_is_whitelisted(protocol_name)) {
56 orig_handler = zend_hash_str_find_ptr(
57 SNUFFLEUPAGUS_G(sp_internal_functions_hook), "stream_wrapper_register",
58 sizeof("stream_wrapper_register") - 1);
59 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); 54 orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
60 } 55 }
61} 56}