From a69c64b2bc5756b14605ad39ffad69d09c0d578c Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Sat, 22 Nov 2014 16:13:15 +0100 Subject: TSRM related speed optimization - thanks to patch from NewEraCracker --- ex_imp.c | 8 +------- execute.c | 2 +- memory_limit.c | 3 +-- php_suhosin.h | 6 +++--- sha256.c | 8 +------- suhosin.c | 6 +++--- suhosin_rfc1867.h | 2 +- ufilter.c | 6 ++---- 8 files changed, 13 insertions(+), 28 deletions(-) diff --git a/ex_imp.c b/ex_imp.c index 6256f35..441314d 100644 --- a/ex_imp.c +++ b/ex_imp.c @@ -668,10 +668,8 @@ zend_function_entry suhosin_ex_imp_functions[] = { }; /* }}} */ -void suhosin_hook_ex_imp() +void suhosin_hook_ex_imp(TSRMLS_D) { - TSRMLS_FETCH(); - /* replace the extract and import_request_variables functions */ zend_hash_del(CG(function_table), "extract", sizeof("extract")); #ifdef SUHOSIN_HAVE_IRV @@ -682,10 +680,6 @@ void suhosin_hook_ex_imp() #else zend_register_functions(NULL, suhosin_ex_imp_functions, NULL, MODULE_PERSISTENT TSRMLS_CC); #endif - - - - } diff --git a/execute.c b/execute.c index a27d82f..ee8447e 100644 --- a/execute.c +++ b/execute.c @@ -1677,7 +1677,7 @@ internal_function_handler ihandlers[] = { #define FUNCTION_WARNING() zend_error(E_WARNING, "%s() has been disabled for security reasons", get_active_function_name(TSRMLS_C)); #define FUNCTION_SIMULATE_WARNING() zend_error(E_WARNING, "SIMULATION - %s() has been disabled for security reasons", get_active_function_name(TSRMLS_C)); -/* {{{ void suhosin_execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC) +/* {{{ void suhosin_execute_internal * This function provides a hook for internal execution */ #if PHP_VERSION_ID >= 50500 #define EX_T(offset) (*EX_TMP_VAR(execute_data_ptr, offset)) diff --git a/memory_limit.c b/memory_limit.c index 6a6b975..be05773 100644 --- a/memory_limit.c +++ b/memory_limit.c @@ -74,10 +74,9 @@ static PHP_INI_MH(suhosin_OnChangeMemoryLimit) /* }}} */ -void suhosin_hook_memory_limit() +void suhosin_hook_memory_limit(TSRMLS_D) { zend_ini_entry *ini_entry; - TSRMLS_FETCH(); /* check if we are compiled against memory_limit */ if (zend_hash_find(EG(ini_directives), "memory_limit", sizeof("memory_limit"), (void **) &ini_entry)==FAILURE) { diff --git a/php_suhosin.h b/php_suhosin.h index 28a88eb..7129e49 100644 --- a/php_suhosin.h +++ b/php_suhosin.h @@ -433,10 +433,10 @@ void suhosin_hook_header_handler(); void suhosin_unhook_header_handler(); void suhosin_hook_session(TSRMLS_D); void suhosin_unhook_session(TSRMLS_D); -void suhosin_hook_sha256(); -void suhosin_hook_ex_imp(); +void suhosin_hook_sha256(TSRMLS_D); +void suhosin_hook_ex_imp(TSRMLS_D); void suhosin_hook_treat_data(); -void suhosin_hook_memory_limit(); +void suhosin_hook_memory_limit(TSRMLS_D); void suhosin_hook_execute(TSRMLS_D); void suhosin_unhook_execute(); void suhosin_aes_gentables(); diff --git a/sha256.c b/sha256.c index 7f542f3..275dccd 100644 --- a/sha256.c +++ b/sha256.c @@ -402,10 +402,8 @@ static zend_function_entry suhosin_sha256_functions[] = { /* }}} */ -void suhosin_hook_sha256() +void suhosin_hook_sha256(TSRMLS_D) { - TSRMLS_FETCH(); - /* check if we already have sha256 support */ if (zend_hash_exists(CG(function_table), "sha256", sizeof("sha256"))) { return; @@ -417,10 +415,6 @@ void suhosin_hook_sha256() #else zend_register_functions(NULL, suhosin_sha256_functions, NULL, MODULE_PERSISTENT TSRMLS_CC); #endif - - - - } diff --git a/suhosin.c b/suhosin.c index 181f702..3071bc1 100644 --- a/suhosin.c +++ b/suhosin.c @@ -1046,9 +1046,9 @@ PHP_MINIT_FUNCTION(suhosin) } /* now hook a bunch of stuff */ - suhosin_hook_memory_limit(); - suhosin_hook_sha256(); - suhosin_hook_ex_imp(); + suhosin_hook_memory_limit(TSRMLS_C); + suhosin_hook_sha256(TSRMLS_C); + suhosin_hook_ex_imp(TSRMLS_C); #if PHP_VERSION_ID < 50500 /* register the logo for phpinfo */ diff --git a/suhosin_rfc1867.h b/suhosin_rfc1867.h index b4fdea0..192089c 100644 --- a/suhosin_rfc1867.h +++ b/suhosin_rfc1867.h @@ -78,7 +78,7 @@ typedef struct _multipart_event_end { SAPI_POST_HANDLER_FUNC(suhosin_rfc1867_post_handler); -void destroy_uploaded_files_hash(TSRMLS_D); +// void destroy_uploaded_files_hash(TSRMLS_D); extern PHP_SUHOSIN_API int (*old_rfc1867_callback)(unsigned int event, void *event_data, void **extra TSRMLS_DC); #if !HAVE_RFC1867_CALLBACK extern PHP_SUHOSIN_API int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra TSRMLS_DC); diff --git a/ufilter.c b/ufilter.c index b6c5986..1110e7c 100644 --- a/ufilter.c +++ b/ufilter.c @@ -32,7 +32,6 @@ #include "suhosin_rfc1867.h" #include "ext/standard/php_var.h" -PHP_SUHOSIN_API int (*old_rfc1867_callback)(unsigned int event, void *event_data, void **extra TSRMLS_DC) = NULL; #if !HAVE_RFC1867_CALLBACK PHP_SUHOSIN_API int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **extra TSRMLS_DC) = NULL; #endif @@ -40,11 +39,10 @@ PHP_SUHOSIN_API int (*php_rfc1867_callback)(unsigned int event, void *event_data /* {{{ SAPI_UPLOAD_VARNAME_FILTER_FUNC */ -static int check_fileupload_varname(char *varname) +static int check_fileupload_varname(char *varname TSRMLS_DC) { char *index, *prev_index = NULL, *var; unsigned int var_len, total_len, depth = 0; - TSRMLS_FETCH(); var = estrdup(varname); @@ -226,7 +224,7 @@ int suhosin_rfc1867_filter(unsigned int event, void *event_data, void **extra TS } - if (check_fileupload_varname(mefs->name) == FAILURE) { + if (check_fileupload_varname(mefs->name TSRMLS_CC) == FAILURE) { goto continue_with_failure; } } -- cgit v1.3