summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2018-10-06 11:26:32 +0200
committerjvoisin2018-10-06 11:26:32 +0200
commit228fadf307b167a22ad6ec760f3b2ee2e9f2fee3 (patch)
tree5aa52bad7cb0eb4e953a9d978f2ad32197dd2cb7
parentfc6e2455c5fcc2a5ec365552fb8d89a9c0571154 (diff)
Remove sp_terminate and bump a bit the coverage
-rw-r--r--src/php_snuffleupagus.h2
-rw-r--r--src/snuffleupagus.c2
-rw-r--r--src/sp_disabled_functions.c8
-rw-r--r--src/sp_execute.c12
-rw-r--r--src/sp_unserialize.c2
-rw-r--r--src/sp_upload_validation.c2
-rw-r--r--src/sp_utils.c2
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()
85PHP_FUNCTION(check_disabled_function); 85PHP_FUNCTION(check_disabled_function);
86PHP_FUNCTION(eval_blacklist_callback); 86PHP_FUNCTION(eval_blacklist_callback);
87 87
88static inline void sp_terminate() { zend_bailout(); }
89
90#endif /* PHP_SNUFFLEUPAGUS_H */ 88#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);
20 20
21ZEND_EXTENSION(); 21ZEND_EXTENSION();
22 22
23// LCOV_EXCL_START
23ZEND_DLEXPORT int sp_zend_startup(zend_extension *extension) { 24ZEND_DLEXPORT int sp_zend_startup(zend_extension *extension) {
24 return zend_startup_module(&snuffleupagus_module_entry); 25 return zend_startup_module(&snuffleupagus_module_entry);
25} 26}
27// LCOV_EXCL_END
26 28
27static inline void sp_op_array_handler(zend_op_array *op) { 29static inline void sp_op_array_handler(zend_op_array *op) {
28 if (NULL == op->filename) { 30 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) {
509 SNUFFLEUPAGUS_G(config) 509 SNUFFLEUPAGUS_G(config)
510 .config_disabled_functions_reg->disabled_functions, 510 .config_disabled_functions_reg->disabled_functions,
511 SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked)) { 511 SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked)) {
512 sp_terminate(); 512 zend_bailout();
513 } 513 }
514 514
515 orig_handler = zend_hash_str_find_ptr( 515 orig_handler = zend_hash_str_find_ptr(
@@ -523,7 +523,7 @@ ZEND_FUNCTION(check_disabled_function) {
523 .config_disabled_functions_reg_ret->disabled_functions, 523 .config_disabled_functions_reg_ret->disabled_functions,
524 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked, 524 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked,
525 execute_data)) { 525 execute_data)) {
526 sp_terminate(); 526 zend_bailout();
527 } 527 }
528} 528}
529 529
@@ -594,7 +594,7 @@ ZEND_FUNCTION(eval_blacklist_callback) {
594 sp_log_msg("eval", SP_LOG_DROP, 594 sp_log_msg("eval", SP_LOG_DROP,
595 "A call to %s was tried in eval, in %s:%d, dropping it.", 595 "A call to %s was tried in eval, in %s:%d, dropping it.",
596 current_function_name, ZSTR_VAL(filename), line_number); 596 current_function_name, ZSTR_VAL(filename), line_number);
597 sp_terminate(); 597 zend_bailout();
598 } 598 }
599 efree(filename); 599 efree(filename);
600 } 600 }
@@ -653,7 +653,7 @@ int hook_echo(const char* str, size_t str_length) {
653 zend_string_release(zs); 653 zend_string_release(zs);
654 654
655 if (ret) { 655 if (ret) {
656 sp_terminate(); 656 zend_bailout();
657 } 657 }
658 658
659 return zend_write_default(str, str_length); 659 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) {
27 } else { 27 } else {
28 sp_log_msg("readonly_exec", SP_LOG_DROP, 28 sp_log_msg("readonly_exec", SP_LOG_DROP,
29 "Attempted execution of a writable file (%s).", filename); 29 "Attempted execution of a writable file (%s).", filename);
30 sp_terminate(); 30 zend_bailout();
31 } 31 }
32 } else { 32 } else {
33 if (EACCES != errno) { 33 if (EACCES != errno) {
@@ -52,7 +52,7 @@ inline static void is_builtin_matching(
52 SNUFFLEUPAGUS_G(config) 52 SNUFFLEUPAGUS_G(config)
53 .config_disabled_functions_reg->disabled_functions, 53 .config_disabled_functions_reg->disabled_functions,
54 ht)) { 54 ht)) {
55 sp_terminate(); 55 zend_bailout();
56 } 56 }
57} 57}
58 58
@@ -95,7 +95,7 @@ is_in_eval_and_whitelisted(const zend_execute_data *execute_data) {
95 "Eval_whitelist", SP_LOG_DROP, 95 "Eval_whitelist", SP_LOG_DROP,
96 "The function '%s' isn't in the eval whitelist, dropping its call.", 96 "The function '%s' isn't in the eval whitelist, dropping its call.",
97 ZSTR_VAL(current_function)); 97 ZSTR_VAL(current_function));
98 sp_terminate(); 98 zend_bailout();
99 } 99 }
100 } 100 }
101 } 101 }
@@ -170,7 +170,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) {
170 should_disable_ht(execute_data, function_name, NULL, NULL, 170 should_disable_ht(execute_data, function_name, NULL, NULL,
171 config_disabled_functions_reg, 171 config_disabled_functions_reg,
172 config_disabled_functions))) { 172 config_disabled_functions))) {
173 sp_terminate(); 173 zend_bailout();
174 } 174 }
175 } else if ((execute_data->prev_execute_data->opline->opcode == 175 } else if ((execute_data->prev_execute_data->opline->opcode ==
176 ZEND_DO_FCALL || 176 ZEND_DO_FCALL ||
@@ -182,7 +182,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) {
182 should_disable_ht(execute_data, function_name, NULL, NULL, 182 should_disable_ht(execute_data, function_name, NULL, NULL,
183 config_disabled_functions_reg, 183 config_disabled_functions_reg,
184 config_disabled_functions))) { 184 config_disabled_functions))) {
185 sp_terminate(); 185 zend_bailout();
186 } 186 }
187 } 187 }
188 188
@@ -203,7 +203,7 @@ static void sp_execute_ex(zend_execute_data *execute_data) {
203 .config_disabled_functions_reg_ret->disabled_functions, 203 .config_disabled_functions_reg_ret->disabled_functions,
204 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, 204 SNUFFLEUPAGUS_G(config).config_disabled_functions_ret,
205 execute_data))) { 205 execute_data))) {
206 sp_terminate(); 206 zend_bailout();
207 } 207 }
208 efree(function_name); 208 efree(function_name);
209 209
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) {
28 if (len < Z_STRLEN_P(return_value)) { 28 if (len < Z_STRLEN_P(return_value)) {
29 sp_log_err("overflow_error", 29 sp_log_err("overflow_error",
30 "Overflow tentative detected in sp_serialize."); 30 "Overflow tentative detected in sp_serialize.");
31 sp_terminate(); 31 zend_bailout();
32 } 32 }
33 zend_string *res = zend_string_alloc(len, 0); 33 zend_string *res = zend_string_alloc(len, 0);
34 34
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) {
86 "The upload of %s on %s was rejected.", filename, 86 "The upload of %s on %s was rejected.", filename,
87 uri ? uri : "?"); 87 uri ? uri : "?");
88 if (!config_upload->simulation) { 88 if (!config_upload->simulation) {
89 sp_terminate(); 89 zend_bailout();
90 } 90 }
91 } 91 }
92 } 92 }
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) {
135 if (ZSTR_LEN(zs) + 1 < ZSTR_LEN(zs)) { 135 if (ZSTR_LEN(zs) + 1 < ZSTR_LEN(zs)) {
136 sp_log_err("overflow_error", 136 sp_log_err("overflow_error",
137 "Overflow tentative detected in zend_string_to_char"); 137 "Overflow tentative detected in zend_string_to_char");
138 sp_terminate(); 138 zend_bailout();
139 } 139 }
140 140
141 char* copy = ecalloc(ZSTR_LEN(zs) + 1, 1); 141 char* copy = ecalloc(ZSTR_LEN(zs) + 1, 1);