From 228fadf307b167a22ad6ec760f3b2ee2e9f2fee3 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 6 Oct 2018 11:26:32 +0200 Subject: Remove sp_terminate and bump a bit the coverage --- src/php_snuffleupagus.h | 2 -- src/snuffleupagus.c | 2 ++ src/sp_disabled_functions.c | 8 ++++---- src/sp_execute.c | 12 ++++++------ src/sp_unserialize.c | 2 +- src/sp_upload_validation.c | 2 +- src/sp_utils.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h index 0bdf602..f5ae6ae 100644 --- a/src/php_snuffleupagus.h +++ b/src/php_snuffleupagus.h @@ -85,6 +85,4 @@ ZEND_TSRMLS_CACHE_EXTERN() PHP_FUNCTION(check_disabled_function); PHP_FUNCTION(eval_blacklist_callback); -static inline void sp_terminate() { zend_bailout(); } - #endif /* PHP_SNUFFLEUPAGUS_H */ diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index 0126a37..2b30502 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c @@ -20,9 +20,11 @@ static inline void sp_op_array_handler(zend_op_array *op); ZEND_EXTENSION(); +// LCOV_EXCL_START ZEND_DLEXPORT int sp_zend_startup(zend_extension *extension) { return zend_startup_module(&snuffleupagus_module_entry); } +// LCOV_EXCL_END static inline void sp_op_array_handler(zend_op_array *op) { if (NULL == op->filename) { diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index b8ec845..1589cd4 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c @@ -509,7 +509,7 @@ ZEND_FUNCTION(check_disabled_function) { SNUFFLEUPAGUS_G(config) .config_disabled_functions_reg->disabled_functions, SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked)) { - sp_terminate(); + zend_bailout(); } orig_handler = zend_hash_str_find_ptr( @@ -523,7 +523,7 @@ ZEND_FUNCTION(check_disabled_function) { .config_disabled_functions_reg_ret->disabled_functions, SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked, execute_data)) { - sp_terminate(); + zend_bailout(); } } @@ -594,7 +594,7 @@ ZEND_FUNCTION(eval_blacklist_callback) { sp_log_msg("eval", SP_LOG_DROP, "A call to %s was tried in eval, in %s:%d, dropping it.", current_function_name, ZSTR_VAL(filename), line_number); - sp_terminate(); + zend_bailout(); } efree(filename); } @@ -653,7 +653,7 @@ int hook_echo(const char* str, size_t str_length) { zend_string_release(zs); if (ret) { - sp_terminate(); + zend_bailout(); } return zend_write_default(str, str_length); diff --git a/src/sp_execute.c b/src/sp_execute.c index 60d63ab..6ed87cb 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c @@ -27,7 +27,7 @@ ZEND_COLD static inline void terminate_if_writable(const char *filename) { } else { sp_log_msg("readonly_exec", SP_LOG_DROP, "Attempted execution of a writable file (%s).", filename); - sp_terminate(); + zend_bailout(); } } else { if (EACCES != errno) { @@ -52,7 +52,7 @@ inline static void is_builtin_matching( SNUFFLEUPAGUS_G(config) .config_disabled_functions_reg->disabled_functions, ht)) { - sp_terminate(); + zend_bailout(); } } @@ -95,7 +95,7 @@ is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { "Eval_whitelist", SP_LOG_DROP, "The function '%s' isn't in the eval whitelist, dropping its call.", ZSTR_VAL(current_function)); - sp_terminate(); + zend_bailout(); } } } @@ -170,7 +170,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { should_disable_ht(execute_data, function_name, NULL, NULL, config_disabled_functions_reg, config_disabled_functions))) { - sp_terminate(); + zend_bailout(); } } else if ((execute_data->prev_execute_data->opline->opcode == ZEND_DO_FCALL || @@ -182,7 +182,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { should_disable_ht(execute_data, function_name, NULL, NULL, config_disabled_functions_reg, config_disabled_functions))) { - sp_terminate(); + zend_bailout(); } } @@ -203,7 +203,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) { .config_disabled_functions_reg_ret->disabled_functions, SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, execute_data))) { - sp_terminate(); + zend_bailout(); } efree(function_name); diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c index fb44ce4..1b47416 100644 --- a/src/sp_unserialize.c +++ b/src/sp_unserialize.c @@ -28,7 +28,7 @@ PHP_FUNCTION(sp_serialize) { if (len < Z_STRLEN_P(return_value)) { sp_log_err("overflow_error", "Overflow tentative detected in sp_serialize."); - sp_terminate(); + zend_bailout(); } zend_string *res = zend_string_alloc(len, 0); diff --git a/src/sp_upload_validation.c b/src/sp_upload_validation.c index 6fa721e..d04dce4 100644 --- a/src/sp_upload_validation.c +++ b/src/sp_upload_validation.c @@ -86,7 +86,7 @@ int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra) { "The upload of %s on %s was rejected.", filename, uri ? uri : "?"); if (!config_upload->simulation) { - sp_terminate(); + zend_bailout(); } } } diff --git a/src/sp_utils.c b/src/sp_utils.c index 8401a92..3e542f7 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c @@ -135,7 +135,7 @@ static char* zend_string_to_char(const zend_string* zs) { if (ZSTR_LEN(zs) + 1 < ZSTR_LEN(zs)) { sp_log_err("overflow_error", "Overflow tentative detected in zend_string_to_char"); - sp_terminate(); + zend_bailout(); } char* copy = ecalloc(ZSTR_LEN(zs) + 1, 1); -- cgit v1.3