summaryrefslogtreecommitdiff
path: root/src/sp_disabled_functions.c
diff options
context:
space:
mode:
authorkkadosh2018-06-28 21:43:40 +0000
committerjvoisin2018-06-28 21:43:40 +0000
commitca3be84076521c4bb053511775c94c0b195aeac8 (patch)
tree3026bd494850086795a67d18f56264abbe4cc11c /src/sp_disabled_functions.c
parent7832438b7abedf567ce6376f99949f419abcdff1 (diff)
Better handling of filters for builtins
Diffstat (limited to 'src/sp_disabled_functions.c')
-rw-r--r--src/sp_disabled_functions.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index eeee007..341c0a4 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -248,6 +248,23 @@ static zend_execute_data* is_file_matching(
248#undef ITERATE 248#undef ITERATE
249} 249}
250 250
251static bool check_is_builtin_name(
252 sp_disabled_function const* const config_node) {
253 if (config_node->function) {
254 return (!strcmp(config_node->function, "include") ||
255 !strcmp(config_node->function, "include_once") ||
256 !strcmp(config_node->function, "require") ||
257 !strcmp(config_node->function, "require_once"));
258 }
259 if (config_node->r_function) {
260 return (sp_is_regexp_matching(config_node->r_function, "include") ||
261 sp_is_regexp_matching(config_node->r_function, "include_once") ||
262 sp_is_regexp_matching(config_node->r_function, "require") ||
263 sp_is_regexp_matching(config_node->r_function, "require_once"));
264 }
265 return false;
266}
267
251bool should_disable(zend_execute_data* execute_data, const char* builtin_name, 268bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
252 const char* builtin_param, const char* builtin_param_name) { 269 const char* builtin_param, const char* builtin_param_name) {
253 char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; 270 char current_file_hash[SHA256_SIZE * 2 + 1] = {0};
@@ -303,13 +320,11 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
303 goto next; 320 goto next;
304 } 321 }
305 } 322 }
306
307 if (config_node->line) { 323 if (config_node->line) {
308 if (config_node->line != zend_get_executed_lineno()) { 324 if (config_node->line != zend_get_executed_lineno()) {
309 goto next; 325 goto next;
310 } 326 }
311 } 327 }
312
313 if (config_node->filename || config_node->r_filename) { 328 if (config_node->filename || config_node->r_filename) {
314 zend_execute_data* ex = 329 zend_execute_data* ex =
315 is_file_matching(execute_data, config_node, current_filename); 330 is_file_matching(execute_data, config_node, current_filename);
@@ -327,7 +342,6 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
327 goto next; 342 goto next;
328 } 343 }
329 } 344 }
330
331 if (config_node->var) { 345 if (config_node->var) {
332 if (false == is_local_var_matching(execute_data, config_node)) { 346 if (false == is_local_var_matching(execute_data, config_node)) {
333 goto next; 347 goto next;
@@ -360,8 +374,17 @@ bool should_disable(zend_execute_data* execute_data, const char* builtin_name,
360 } 374 }
361 } 375 }
362 376
363 /* Everything matched.*/ 377 if (config_node->value_r || config_node->value) {
378 if (check_is_builtin_name(config_node)) {
379 if (false == is_param_matching(execute_data, config_node, builtin_name,
380 builtin_param, &arg_name,
381 builtin_param_name, &arg_value_str)) {
382 goto next;
383 }
384 }
385 }
364 386
387 /* Everything matched.*/
365 if (true == config_node->allow) { 388 if (true == config_node->allow) {
366 goto allow; 389 goto allow;
367 } 390 }