From 39929ce509361ee72746a9b971bdc531fbf0b843 Mon Sep 17 00:00:00 2001 From: kkadosh Date: Mon, 19 Mar 2018 16:39:47 +0000 Subject: The filename filter is now matching on callsite instead of implemsite (#167) * Add match on the file where the function is called * Add the test * Constify some params * Fix potentiel null deref * Return more before if execute_data is NULL --- src/sp_utils.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/sp_utils.c') diff --git a/src/sp_utils.c b/src/sp_utils.c index 54a8e1b..5f34ccc 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c @@ -189,39 +189,38 @@ bool sp_match_value(const char* value, const char* to_match, void sp_log_disable(const char* restrict path, const char* restrict arg_name, const char* restrict arg_value, - const sp_disabled_function* config_node) { + const sp_disabled_function* config_node, unsigned int line, + const char* restrict filename) { const char* dump = config_node->dump; const char* alias = config_node->alias; const int sim = config_node->simulation; + + filename = filename ? filename : zend_get_executed_filename(TSRMLS_C); + line = line ? line : zend_get_executed_lineno(TSRMLS_C); + if (arg_name) { if (alias) { sp_log_msg( "disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, "The call to the function '%s' in %s:%d has been disabled, " "because its argument '%s' content (%s) matched the rule '%s'.", - path, zend_get_executed_filename(TSRMLS_C), - zend_get_executed_lineno(TSRMLS_C), arg_name, - arg_value ? arg_value : "?", alias); + path, filename, line, arg_name, arg_value ? arg_value : "?", alias); } else { sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, "The call to the function '%s' in %s:%d has been disabled, " "because its argument '%s' content (%s) matched a rule.", - path, zend_get_executed_filename(TSRMLS_C), - zend_get_executed_lineno(TSRMLS_C), arg_name, - arg_value ? arg_value : "?"); + path, filename, line, arg_name, arg_value ? arg_value : "?"); } } else { if (alias) { sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, "The call to the function '%s' in %s:%d has been disabled, " "because of the the rule '%s'.", - path, zend_get_executed_filename(TSRMLS_C), - zend_get_executed_lineno(TSRMLS_C), alias); + path, filename, line, alias); } else { sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, "The call to the function '%s' in %s:%d has been disabled.", - path, zend_get_executed_filename(TSRMLS_C), - zend_get_executed_lineno(TSRMLS_C)); + path, filename, line); } } if (dump) { -- cgit v1.3