summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sp_config_keywords.c5
-rw-r--r--src/sp_disabled_functions.c10
-rw-r--r--src/tests/config/disabled_function_print.ini1
-rw-r--r--src/tests/disabled_function_print.phpt18
4 files changed, 26 insertions, 8 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index 81f43f7..8e1c2dc 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -472,6 +472,11 @@ int parse_disabled_functions(char *line) {
472 return ret; 472 return ret;
473 } 473 }
474 474
475 if (df->function && zend_string_equals_literal(df->function, "print")) {
476 zend_string_release(df->function);
477 df->function = zend_string_init("echo", strlen("echo"), 1);
478 }
479
475 if (df->function && !df->functions_list) { 480 if (df->function && !df->functions_list) {
476 if (df->ret || df->r_ret || df->ret_type) { 481 if (df->ret || df->r_ret || df->ret_type) {
477 add_df_to_hashtable(SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, 482 add_df_to_hashtable(SNUFFLEUPAGUS_G(config).config_disabled_functions_ret,
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index f266951..f6e06e4 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -573,14 +573,8 @@ static int hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) {
573 if (!HOOK_FUNCTION(ZSTR_VAL(key), disabled_functions_hook, 573 if (!HOOK_FUNCTION(ZSTR_VAL(key), disabled_functions_hook,
574 PHP_FN(check_disabled_function)) || 574 PHP_FN(check_disabled_function)) ||
575 check_is_builtin_name(((sp_list_node*)Z_PTR_P(value))->data)) { 575 check_is_builtin_name(((sp_list_node*)Z_PTR_P(value))->data)) {
576 if (zend_string_equals_literal(key, "echo") || 576 zend_symtable_add_new(hooked_ht, key, value);
577 zend_string_equals_literal(key, "print")) { 577 zend_hash_del(to_hook_ht, key);
578 zend_hash_str_add_new(hooked_ht, "echo", strlen("echo"), value);
579 zend_hash_del(to_hook_ht, key);
580 } else {
581 zend_symtable_add_new(hooked_ht, key, value);
582 zend_hash_del(to_hook_ht, key);
583 }
584 } 578 }
585 } 579 }
586 ZEND_HASH_FOREACH_END(); 580 ZEND_HASH_FOREACH_END();
diff --git a/src/tests/config/disabled_function_print.ini b/src/tests/config/disabled_function_print.ini
new file mode 100644
index 0000000..22d957f
--- /dev/null
+++ b/src/tests/config/disabled_function_print.ini
@@ -0,0 +1 @@
sp.disable_function.function("print").value("oops").drop();
diff --git a/src/tests/disabled_function_print.phpt b/src/tests/disabled_function_print.phpt
new file mode 100644
index 0000000..fc05360
--- /dev/null
+++ b/src/tests/disabled_function_print.phpt
@@ -0,0 +1,18 @@
1--TEST--
2Echo hooking
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/disabled_function_print.ini
7--FILE--
8<?php
9function test($a) {
10 print "$a";
11}
12print "qwe";
13test("rty");
14test("oops");
15?>
16--CLEAN--
17--EXPECTF--
18qwerty[snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'echo' in %a/tests/disabled_function_print.php:3.