From 432e8f9ab8a3029b16e03676aa643f3788faf14c Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Thu, 22 Jan 2015 12:19:09 +0100 Subject: removed #ifdef ZEND_ENGINE_2 as it is always defined anyway --- ex_imp.c | 4 ---- execute.c | 43 +------------------------------------------ ifilter.c | 6 ++---- log.c | 13 +------------ php_suhosin.h | 7 ------- 5 files changed, 4 insertions(+), 69 deletions(-) diff --git a/ex_imp.c b/ex_imp.c index 1c01191..a46eb43 100644 --- a/ex_imp.c +++ b/ex_imp.c @@ -263,11 +263,7 @@ void suhosin_hook_ex_imp(TSRMLS_D) { /* replace the extract and import_request_variables functions */ zend_hash_del(CG(function_table), "extract", sizeof("extract")); -#ifndef ZEND_ENGINE_2 - zend_register_functions(suhosin_ex_imp_functions, NULL, MODULE_PERSISTENT TSRMLS_CC); -#else zend_register_functions(NULL, suhosin_ex_imp_functions, NULL, MODULE_PERSISTENT TSRMLS_CC); -#endif } diff --git a/execute.c b/execute.c index 9c078f7..7f646fe 100644 --- a/execute.c +++ b/execute.c @@ -257,22 +257,11 @@ SDEBUG("xxx %p %p",SUHOSIN_G(include_whitelist),SUHOSIN_G(include_blacklist)); } -#ifdef ZEND_ENGINE_2 static int (*old_zend_stream_open)(const char *filename, zend_file_handle *fh TSRMLS_DC); -#else -static zend_bool (*old_zend_open)(const char *filename, zend_file_handle *fh); -#endif -#ifdef ZEND_ENGINE_2 static int suhosin_zend_stream_open(const char *filename, zend_file_handle *fh TSRMLS_DC) { zend_execute_data *exd; -#else -static zend_bool suhosin_zend_open(const char *filename, zend_file_handle *fh) -{ - zend_execute_data *exd; - TSRMLS_FETCH(); -#endif exd=EG(current_execute_data); if (EG(in_execution) && (exd!=NULL) && (exd->opline != NULL) && (exd->opline->opcode == ZEND_INCLUDE_OR_EVAL)) { int filetype = suhosin_check_filename((char *)filename, strlen(filename) TSRMLS_CC); @@ -314,11 +303,7 @@ static zend_bool suhosin_zend_open(const char *filename, zend_file_handle *fh) break; } } -#ifdef ZEND_ENGINE_2 return old_zend_stream_open(filename, fh TSRMLS_CC); -#else - return old_zend_open(filename, fh); -#endif } @@ -458,13 +443,7 @@ static void suhosin_execute_ex(zend_op_array *op_array, int zo, long dummy TSRML code = 200; } -#ifdef ZEND_ENGINE_2 if (zend_stream_open(action, &file_handle TSRMLS_CC) == SUCCESS) { -#else - if (zend_open(action, &file_handle) == SUCCESS && ZEND_IS_VALID_FILE_HANDLE(&file_handle)) { - file_handle.filename = action; - file_handle.free_filename = 0; -#endif if (!file_handle.opened_path) { file_handle.opened_path = estrndup(action, strlen(action)); } @@ -474,15 +453,10 @@ static void suhosin_execute_ex(zend_op_array *op_array, int zo, long dummy TSRML EG(return_value_ptr_ptr) = &result; EG(active_op_array) = new_op_array; zend_execute(new_op_array TSRMLS_CC); -#ifdef ZEND_ENGINE_2 destroy_op_array(new_op_array TSRMLS_CC); -#else - destroy_op_array(new_op_array); -#endif efree(new_op_array); -#ifdef ZEND_ENGINE_2 + if (!EG(exception)) -#endif { if (EG(return_value_ptr_ptr)) { zval_ptr_dtor(EG(return_value_ptr_ptr)); @@ -1685,9 +1659,7 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re zend_class_entry *ce = NULL; internal_function_handler *ih; -#ifdef ZEND_ENGINE_2 ce = ((zend_internal_function *) execute_data_ptr->function_state.function)->scope; -#endif lcname = (char *)((zend_internal_function *) execute_data_ptr->function_state.function)->function_name; function_name_strlen = strlen(lcname); @@ -1705,11 +1677,7 @@ static void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int re } #if PHP_VERSION_ID < 50500 -#ifdef ZEND_ENGINE_2 return_value = (*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.var)).var.ptr; -#else - return_value = execute_data_ptr->Ts[execute_data_ptr->opline->result.u.var].var.ptr; -#endif #endif SDEBUG("function: %s", lcname); @@ -1860,13 +1828,8 @@ void suhosin_hook_execute(TSRMLS_D) /* Add additional protection layer, that SHOULD catch ZEND_INCLUDE_OR_EVAL *before* the engine tries to execute */ -#ifdef ZEND_ENGINE_2 old_zend_stream_open = zend_stream_open_function; zend_stream_open_function = suhosin_zend_stream_open; -#else - old_zend_open = zend_open; - zend_open = suhosin_zend_open; -#endif } /* }}} */ @@ -1897,11 +1860,7 @@ void suhosin_unhook_execute() zend_hash_clean(&ihandler_table); /* remove zend_open protection */ -#ifdef ZEND_ENGINE_2 zend_stream_open_function = old_zend_stream_open; -#else - zend_open = old_zend_open; -#endif } /* }}} */ diff --git a/ifilter.c b/ifilter.c index 47ab6f2..d7e2f2e 100644 --- a/ifilter.c +++ b/ifilter.c @@ -281,9 +281,8 @@ void suhosin_register_server_variables(zval *track_vars_array TSRMLS_DC) /* }}} */ -#ifdef ZEND_ENGINE_2 - /* Old Input filter */ - unsigned int (*old_input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) = NULL; +/* Old Input filter */ +unsigned int (*old_input_filter)(int arg, char *var, char **val, unsigned int val_len, unsigned int *new_val_len TSRMLS_DC) = NULL; /* {{{ suhosin_input_filter_wrapper */ @@ -314,7 +313,6 @@ unsigned int suhosin_input_filter_wrapper(int arg, char *var, char **val, unsign return 1; } } -#endif /* {{{ suhosin_input_filter */ diff --git a/log.c b/log.c index f76737c..b819eca 100644 --- a/log.c +++ b/log.c @@ -372,13 +372,7 @@ log_phpscript: char *phpscript = SUHOSIN_G(log_phpscriptname); SDEBUG("scriptname %s", SUHOSIN_G(log_phpscriptname)); -#ifdef ZEND_ENGINE_2 if (zend_stream_open(phpscript, &file_handle TSRMLS_CC) == SUCCESS) { -#else - if (zend_open(phpscript, &file_handle) == SUCCESS && ZEND_IS_VALID_FILE_HANDLE(&file_handle)) { - file_handle.filename = phpscript; - file_handle.free_filename = 0; -#endif if (!file_handle.opened_path) { file_handle.opened_path = estrndup(phpscript, strlen(phpscript)); } @@ -412,15 +406,10 @@ SDEBUG("scriptname %s", SUHOSIN_G(log_phpscriptname)); SUHOSIN_G(execution_depth) = orig_execution_depth; PG(open_basedir) = orig_basedir; -#ifdef ZEND_ENGINE_2 destroy_op_array(new_op_array TSRMLS_CC); -#else - destroy_op_array(new_op_array); -#endif efree(new_op_array); -#ifdef ZEND_ENGINE_2 + if (!EG(exception)) -#endif { if (EG(return_value_ptr_ptr)) { zval_ptr_dtor(EG(return_value_ptr_ptr)); diff --git a/php_suhosin.h b/php_suhosin.h index d5a20ab..80d75ba 100644 --- a/php_suhosin.h +++ b/php_suhosin.h @@ -330,13 +330,6 @@ ZEND_END_MODULE_GLOBALS(suhosin) #ifndef ZEND_INI_STAGE_HTACCESS #define ZEND_INI_STAGE_HTACCESS (1<<5) #endif - -#ifndef ZEND_ENGINE_2 -#define OnUpdateLong OnUpdateInt -#define zend_symtable_find zend_hash_find -#define zend_symtable_update zend_hash_update -#define zend_symtable_exists zend_hash_exists -#endif /* Error Constants */ -- cgit v1.3