From 6f21bff1d40326f69bc3b75b1b83b03623180365 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 10 Jan 2018 17:38:24 +0100 Subject: Rework the priority of bl/wl in eval --- src/sp_utils.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/sp_utils.c') diff --git a/src/sp_utils.c b/src/sp_utils.c index 8a1ed87..19b7179 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c @@ -7,6 +7,8 @@ #include #include +ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) + static inline void _sp_log_err(const char* fmt, ...) { char* msg; va_list args; @@ -394,3 +396,22 @@ int hook_regexp(const pcre* regexp, HashTable* hook_table, ZEND_HASH_FOREACH_END(); return SUCCESS; } + +bool check_is_in_eval_whitelist(const char* const function_name) { + const sp_list_node* it = SNUFFLEUPAGUS_G(config).config_eval->whitelist; + + if (!it->head) { + return false; + } + + /* yes, we could use a HashTable instead, but since the list is pretty + * small, it doesn't maka a difference in practise. */ + while (it && it->data) { + if (0 == strcmp(function_name, (char*)(it->data))) { + /* We've got a match, the function is whiteslited. */ + return true; + } + it = it->next; + } + return false; +} -- cgit v1.3