summaryrefslogtreecommitdiff
path: root/src/sp_disabled_functions.c
diff options
context:
space:
mode:
authorThibault "bui" Koechlin2017-10-19 18:05:37 +0200
committerGitHub2017-10-19 18:05:37 +0200
commit8d3a23b2cc4cc433706706db5ba5fbfb24e06b7c (patch)
tree69b4cecad32571120b9cd6edbdc2f0525805fa9d /src/sp_disabled_functions.c
parente8d255e5cef8949256d3290b2d8fd22de9428a83 (diff)
parent066b79abe9943821240ccc3a458e8ba45b9ee9e8 (diff)
Merge pull request #33 from nbs-system/4-match-on-arg-pos
Implement match on arguments position
Diffstat (limited to 'src/sp_disabled_functions.c')
-rw-r--r--src/sp_disabled_functions.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index c8c723a..54a1906 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -178,11 +178,17 @@ bool should_disable(zend_execute_data* execute_data) {
178 } 178 }
179 179
180 /* Check if we filter on parameter value*/ 180 /* Check if we filter on parameter value*/
181 if (config_node->param || config_node->r_param) { 181 if (config_node->param || config_node->r_param || (config_node->pos != -1)) {
182 const unsigned int nb_param = execute_data->func->common.num_args; 182 int nb_param = execute_data->func->common.num_args;
183 bool arg_matched = false; 183 bool arg_matched = false;
184 int i = 0;
184 185
185 for (unsigned int i = 0; i < nb_param; i++) { 186 if ((config_node->pos != -1) && (config_node->pos <= nb_param)) {
187 i = config_node->pos;
188 nb_param = (config_node->pos) + 1;
189 }
190
191 for (; i < nb_param; i++) {
186 arg_matched = false; 192 arg_matched = false;
187 if (ZEND_USER_CODE(execute_data->func->type)) { // yay consistency 193 if (ZEND_USER_CODE(execute_data->func->type)) { // yay consistency
188 arg_name = ZSTR_VAL(execute_data->func->common.arg_info[i].name); 194 arg_name = ZSTR_VAL(execute_data->func->common.arg_info[i].name);
@@ -197,7 +203,7 @@ bool should_disable(zend_execute_data* execute_data) {
197 (true == is_regexp_matching(config_node->r_param, arg_name)); 203 (true == is_regexp_matching(config_node->r_param, arg_name));
198 204
199 /* This is the parameter name we're looking for. */ 205 /* This is the parameter name we're looking for. */
200 if (true == arg_matching || true == pcre_matching) { 206 if (true == arg_matching || true == pcre_matching || (config_node->pos != -1)) {
201 zval* arg_value = ZEND_CALL_VAR_NUM(execute_data, i); 207 zval* arg_value = ZEND_CALL_VAR_NUM(execute_data, i);
202 208
203 if (config_node->param_type) { // Are we matching on the `type`? 209 if (config_node->param_type) { // Are we matching on the `type`?