summaryrefslogtreecommitdiff
path: root/src/sp_utils.c
diff options
context:
space:
mode:
authorkkadosh2018-03-19 16:39:47 +0000
committerblotus2018-03-19 17:39:47 +0100
commit39929ce509361ee72746a9b971bdc531fbf0b843 (patch)
treec3455c4e4428d3b613e926b28619396960a2713e /src/sp_utils.c
parent3659eb1542270d25c36fb3f38600e85cb8b6a22b (diff)
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
Diffstat (limited to 'src/sp_utils.c')
-rw-r--r--src/sp_utils.c21
1 files changed, 10 insertions, 11 deletions
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,
189 189
190void sp_log_disable(const char* restrict path, const char* restrict arg_name, 190void sp_log_disable(const char* restrict path, const char* restrict arg_name,
191 const char* restrict arg_value, 191 const char* restrict arg_value,
192 const sp_disabled_function* config_node) { 192 const sp_disabled_function* config_node, unsigned int line,
193 const char* restrict filename) {
193 const char* dump = config_node->dump; 194 const char* dump = config_node->dump;
194 const char* alias = config_node->alias; 195 const char* alias = config_node->alias;
195 const int sim = config_node->simulation; 196 const int sim = config_node->simulation;
197
198 filename = filename ? filename : zend_get_executed_filename(TSRMLS_C);
199 line = line ? line : zend_get_executed_lineno(TSRMLS_C);
200
196 if (arg_name) { 201 if (arg_name) {
197 if (alias) { 202 if (alias) {
198 sp_log_msg( 203 sp_log_msg(
199 "disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, 204 "disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP,
200 "The call to the function '%s' in %s:%d has been disabled, " 205 "The call to the function '%s' in %s:%d has been disabled, "
201 "because its argument '%s' content (%s) matched the rule '%s'.", 206 "because its argument '%s' content (%s) matched the rule '%s'.",
202 path, zend_get_executed_filename(TSRMLS_C), 207 path, filename, line, arg_name, arg_value ? arg_value : "?", alias);
203 zend_get_executed_lineno(TSRMLS_C), arg_name,
204 arg_value ? arg_value : "?", alias);
205 } else { 208 } else {
206 sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, 209 sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP,
207 "The call to the function '%s' in %s:%d has been disabled, " 210 "The call to the function '%s' in %s:%d has been disabled, "
208 "because its argument '%s' content (%s) matched a rule.", 211 "because its argument '%s' content (%s) matched a rule.",
209 path, zend_get_executed_filename(TSRMLS_C), 212 path, filename, line, arg_name, arg_value ? arg_value : "?");
210 zend_get_executed_lineno(TSRMLS_C), arg_name,
211 arg_value ? arg_value : "?");
212 } 213 }
213 } else { 214 } else {
214 if (alias) { 215 if (alias) {
215 sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, 216 sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP,
216 "The call to the function '%s' in %s:%d has been disabled, " 217 "The call to the function '%s' in %s:%d has been disabled, "
217 "because of the the rule '%s'.", 218 "because of the the rule '%s'.",
218 path, zend_get_executed_filename(TSRMLS_C), 219 path, filename, line, alias);
219 zend_get_executed_lineno(TSRMLS_C), alias);
220 } else { 220 } else {
221 sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP, 221 sp_log_msg("disabled_function", sim ? SP_LOG_SIMULATION : SP_LOG_DROP,
222 "The call to the function '%s' in %s:%d has been disabled.", 222 "The call to the function '%s' in %s:%d has been disabled.",
223 path, zend_get_executed_filename(TSRMLS_C), 223 path, filename, line);
224 zend_get_executed_lineno(TSRMLS_C));
225 } 224 }
226 } 225 }
227 if (dump) { 226 if (dump) {