summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sp_execute.c17
-rw-r--r--src/sp_execute.h2
2 files changed, 9 insertions, 10 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c
index 036f1a4..bf9c907 100644
--- a/src/sp_execute.c
+++ b/src/sp_execute.c
@@ -50,8 +50,7 @@ is_in_eval_and_whitelisted(const zend_execute_data *execute_data) {
50 return; 50 return;
51 } 51 }
52 52
53 if (EXPECTED(NULL == SNUFFLEUPAGUS_G(config).config_eval->whitelist || 53 if (EXPECTED(NULL == SNUFFLEUPAGUS_G(config).config_eval->whitelist)) {
54 NULL == SNUFFLEUPAGUS_G(config).config_eval->whitelist->data)) {
55 return; 54 return;
56 } 55 }
57 56
@@ -59,14 +58,14 @@ is_in_eval_and_whitelisted(const zend_execute_data *execute_data) {
59 return; 58 return;
60 } 59 }
61 60
62 if (!(execute_data->func->common.function_name)) { 61 if (UNEXPECTED(!(execute_data->func->common.function_name))) {
63 return; 62 return;
64 } 63 }
65 64
66 char const *const current_function = ZSTR_VAL(EX(func)->common.function_name); 65 char const *const current_function = ZSTR_VAL(EX(func)->common.function_name);
67 66
68 if (EXPECTED(NULL != current_function)) { 67 if (EXPECTED(NULL != current_function)) {
69 if (false == check_is_in_eval_whitelist(current_function)) { 68 if (UNEXPECTED(false == check_is_in_eval_whitelist(current_function))) {
70 sp_log_msg( 69 sp_log_msg(
71 "Eval_whitelist", SP_LOG_DROP, 70 "Eval_whitelist", SP_LOG_DROP,
72 "The function '%s' isn't in the eval whitelist, dropping its call.", 71 "The function '%s' isn't in the eval whitelist, dropping its call.",
@@ -79,7 +78,7 @@ is_in_eval_and_whitelisted(const zend_execute_data *execute_data) {
79/* This function gets the filename in which `eval()` is called from, 78/* This function gets the filename in which `eval()` is called from,
80 * since it looks like "foo.php(1) : eval()'d code", so we're starting 79 * since it looks like "foo.php(1) : eval()'d code", so we're starting
81 * from the end of the string until the second closing parenthesis. */ 80 * from the end of the string until the second closing parenthesis. */
82char *get_eval_filename(const char *filename) { 81char *get_eval_filename(const char *const filename) {
83 size_t i = strlen(filename); 82 size_t i = strlen(filename);
84 int count = 0; 83 int count = 0;
85 char *clean_filename = estrdup(filename); 84 char *clean_filename = estrdup(filename);
@@ -99,11 +98,11 @@ char *get_eval_filename(const char *filename) {
99static void sp_execute_ex(zend_execute_data *execute_data) { 98static void sp_execute_ex(zend_execute_data *execute_data) {
100 is_in_eval_and_whitelisted(execute_data); 99 is_in_eval_and_whitelisted(execute_data);
101 100
102 if (true == should_disable(execute_data, NULL, NULL, NULL)) { 101 if (UNEXPECTED(true == should_disable(execute_data, NULL, NULL, NULL))) {
103 sp_terminate(); 102 sp_terminate();
104 } 103 }
105 104
106 if (EX(func)->op_array.type == ZEND_EVAL_CODE) { 105 if (UNEXPECTED(EX(func)->op_array.type == ZEND_EVAL_CODE)) {
107 SNUFFLEUPAGUS_G(in_eval)++; 106 SNUFFLEUPAGUS_G(in_eval)++;
108 const sp_list_node *config = 107 const sp_list_node *config =
109 SNUFFLEUPAGUS_G(config).config_disabled_constructs->construct_eval; 108 SNUFFLEUPAGUS_G(config).config_disabled_constructs->construct_eval;
@@ -120,11 +119,11 @@ static void sp_execute_ex(zend_execute_data *execute_data) {
120 119
121 orig_execute_ex(execute_data); 120 orig_execute_ex(execute_data);
122 121
123 if (true == should_drop_on_ret(EX(return_value), execute_data)) { 122 if (UNEXPECTED(true == should_drop_on_ret(EX(return_value), execute_data))) {
124 sp_terminate(); 123 sp_terminate();
125 } 124 }
126 125
127 if (ZEND_EVAL_CODE == EX(func)->op_array.type) { 126 if (UNEXPECTED(ZEND_EVAL_CODE == EX(func)->op_array.type)) {
128 SNUFFLEUPAGUS_G(in_eval)--; 127 SNUFFLEUPAGUS_G(in_eval)--;
129 } 128 }
130} 129}
diff --git a/src/sp_execute.h b/src/sp_execute.h
index 6ef50ee..fcd0e11 100644
--- a/src/sp_execute.h
+++ b/src/sp_execute.h
@@ -2,6 +2,6 @@
2#define SP_EXECUTE_H 2#define SP_EXECUTE_H
3 3
4int hook_execute(void); 4int hook_execute(void);
5char *get_eval_filename(const char *filename); 5char *get_eval_filename(const char * const filename);
6 6
7#endif /* SP_EXECUTE_H */ 7#endif /* SP_EXECUTE_H */