summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2018-10-06 23:15:50 +0200
committerjvoisin2018-10-06 23:15:50 +0200
commit41f5fe02575611ac43848a3a95f337e57960d492 (patch)
treeecc5270734280063e20e66876eef89e09ca5b362
parent2d615f1fac1a78012c0cce2e4e9f87c8e6df05b6 (diff)
Bump coverage again
-rw-r--r--src/sp_disabled_functions.c13
-rw-r--r--src/sp_execute.c5
-rw-r--r--src/sp_unserialize.c4
-rw-r--r--src/sp_utils.c2
-rw-r--r--src/tests/disabled_functions.phpt3
5 files changed, 11 insertions, 16 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
index 79dc5a7..b5cbe14 100644
--- a/src/sp_disabled_functions.c
+++ b/src/sp_disabled_functions.c
@@ -7,7 +7,7 @@ ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
7 7
8char* get_complete_function_path(zend_execute_data const* const execute_data) { 8char* get_complete_function_path(zend_execute_data const* const execute_data) {
9 if (zend_is_executing() && !EG(current_execute_data)->func) { 9 if (zend_is_executing() && !EG(current_execute_data)->func) {
10 return NULL; 10 return NULL; // LCOV_EXCL_LINE
11 } 11 }
12 if (!(execute_data->func->common.function_name)) { 12 if (!(execute_data->func->common.function_name)) {
13 return NULL; 13 return NULL;
@@ -259,7 +259,7 @@ bool should_disable_ht(zend_execute_data* execute_data,
259 zend_string* current_filename; 259 zend_string* current_filename;
260 260
261 if (!execute_data) { 261 if (!execute_data) {
262 return false; 262 return false; // LCOV_EXCL_LINE
263 } 263 }
264 264
265 if (UNEXPECTED(builtin_param && !strcmp(function_name, "eval"))) { 265 if (UNEXPECTED(builtin_param && !strcmp(function_name, "eval"))) {
@@ -509,7 +509,6 @@ ZEND_FUNCTION(check_disabled_function) {
509 SNUFFLEUPAGUS_G(config) 509 SNUFFLEUPAGUS_G(config)
510 .config_disabled_functions_reg->disabled_functions, 510 .config_disabled_functions_reg->disabled_functions,
511 SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked)) { 511 SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked)) {
512 zend_bailout();
513 } 512 }
514 513
515 orig_handler = zend_hash_str_find_ptr( 514 orig_handler = zend_hash_str_find_ptr(
@@ -522,7 +521,6 @@ ZEND_FUNCTION(check_disabled_function) {
522 .config_disabled_functions_reg_ret->disabled_functions, 521 .config_disabled_functions_reg_ret->disabled_functions,
523 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked, 522 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked,
524 execute_data)) { 523 execute_data)) {
525 zend_bailout();
526 } 524 }
527} 525}
528 526
@@ -593,7 +591,6 @@ ZEND_FUNCTION(eval_blacklist_callback) {
593 sp_log_msg("eval", SP_LOG_DROP, 591 sp_log_msg("eval", SP_LOG_DROP,
594 "A call to %s was tried in eval, in %s:%d, dropping it.", 592 "A call to %s was tried in eval, in %s:%d, dropping it.",
595 current_function_name, ZSTR_VAL(filename), line_number); 593 current_function_name, ZSTR_VAL(filename), line_number);
596 zend_bailout();
597 } 594 }
598 efree(filename); 595 efree(filename);
599 } 596 }
@@ -644,16 +641,12 @@ zend_write_func_t zend_write_default = NULL;
644int hook_echo(const char* str, size_t str_length) { 641int hook_echo(const char* str, size_t str_length) {
645 zend_string* zs = zend_string_init(str, str_length, 0); 642 zend_string* zs = zend_string_init(str, str_length, 0);
646 643
647 bool ret = should_disable_ht( 644 should_disable_ht(
648 EG(current_execute_data), "echo", zs, NULL, 645 EG(current_execute_data), "echo", zs, NULL,
649 SNUFFLEUPAGUS_G(config).config_disabled_functions_reg->disabled_functions, 646 SNUFFLEUPAGUS_G(config).config_disabled_functions_reg->disabled_functions,
650 SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked); 647 SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked);
651 648
652 zend_string_release(zs); 649 zend_string_release(zs);
653 650
654 if (ret) {
655 zend_bailout();
656 }
657
658 return zend_write_default(str, str_length); 651 return zend_write_default(str, str_length);
659} 652}
diff --git a/src/sp_execute.c b/src/sp_execute.c
index e631f7b..fa8fa90 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -223,8 +223,9 @@ static void sp_zend_execute_internal(INTERNAL_FUNCTION_PARAMETERS) {
223 is_in_eval_and_whitelisted(execute_data); 223 is_in_eval_and_whitelisted(execute_data);
224 224
225 if (UNEXPECTED(NULL != orig_zend_execute_internal)) { 225 if (UNEXPECTED(NULL != orig_zend_execute_internal)) {
226 orig_zend_execute_internal( 226 // LCOV_EXCL_START
227 INTERNAL_FUNCTION_PARAM_PASSTHRU); // LCOV_EXCL_LINE 227 orig_zend_execute_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU);
228 // LCOV_EXCL_STOP
228 } else { 229 } else {
229 EX(func)->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); 230 EX(func)->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
230 } 231 }
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c
index fe738e6..5e21d6a 100644
--- a/src/sp_unserialize.c
+++ b/src/sp_unserialize.c
@@ -97,8 +97,8 @@ PHP_FUNCTION(sp_unserialize) {
97 } else { 97 } else {
98 if (config_unserialize->dump) { 98 if (config_unserialize->dump) {
99 sp_log_request(config_unserialize->dump, 99 sp_log_request(config_unserialize->dump,
100 config_unserialize->textual_representation, 100 config_unserialize->textual_representation,
101 SP_TOKEN_UNSERIALIZE_HMAC); 101 SP_TOKEN_UNSERIALIZE_HMAC);
102 } 102 }
103 if (true == config_unserialize->simulation) { 103 if (true == config_unserialize->simulation) {
104 sp_log_msg("unserialize", SP_LOG_SIMULATION, "Invalid HMAC for %s", 104 sp_log_msg("unserialize", SP_LOG_SIMULATION, "Invalid HMAC for %s",
diff --git a/src/sp_utils.c b/src/sp_utils.c
index 3def6da..d6d8c00 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -183,7 +183,7 @@ const zend_string* sp_zval_to_zend_string(const zval* zv) {
183 return zend_string_init("ARRAY", sizeof("ARRAY") - 1, 0); 183 return zend_string_init("ARRAY", sizeof("ARRAY") - 1, 0);
184 case IS_RESOURCE: 184 case IS_RESOURCE:
185 return zend_string_init("RESOURCE", sizeof("RESOURCE") - 1, 0); 185 return zend_string_init("RESOURCE", sizeof("RESOURCE") - 1, 0);
186 default: // LCOV_EXCL_LINE 186 default: // LCOV_EXCL_LINE
187 return zend_string_init("", 0, 0); // LCOV_EXCL_LINE 187 return zend_string_init("", 0, 0); // LCOV_EXCL_LINE
188 } 188 }
189} 189}
diff --git a/src/tests/disabled_functions.phpt b/src/tests/disabled_functions.phpt
index 48d3724..6e57dba 100644
--- a/src/tests/disabled_functions.phpt
+++ b/src/tests/disabled_functions.phpt
@@ -6,6 +6,7 @@ Disable functions
6sp.configuration_file={PWD}/config/disabled_functions.ini 6sp.configuration_file={PWD}/config/disabled_functions.ini
7--FILE-- 7--FILE--
8<?php 8<?php
9strcmp("1", "2");
9system("id"); 10system("id");
10printf("printf in simulation mode\n"); 11printf("printf in simulation mode\n");
11print("print in disabled mode\n"); 12print("print in disabled mode\n");
@@ -13,4 +14,4 @@ var_dump("this is a super test");
13echo strpos("pouet", "o"); 14echo strpos("pouet", "o");
14?> 15?>
15--EXPECTF-- 16--EXPECTF--
16Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions.php on line 2 \ No newline at end of file 17Fatal error: [snuffleupagus][disabled_function] Aborted execution on call of the function 'system' in %a/disabled_functions.php on line %d