diff options
| -rw-r--r-- | php_suhosin.h | 1 | ||||
| -rw-r--r-- | post_handler.c | 23 | ||||
| -rw-r--r-- | suhosin.c | 1 |
3 files changed, 25 insertions, 0 deletions
diff --git a/php_suhosin.h b/php_suhosin.h index 93a6b45..1e2e053 100644 --- a/php_suhosin.h +++ b/php_suhosin.h | |||
| @@ -307,6 +307,7 @@ char *suhosin_decrypt_string(char *str, int padded_len, char *var, int vlen, cha | |||
| 307 | char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, char *cryptkey TSRMLS_DC); | 307 | char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, char *cryptkey TSRMLS_DC); |
| 308 | char *suhosin_cookie_decryptor(TSRMLS_D); | 308 | char *suhosin_cookie_decryptor(TSRMLS_D); |
| 309 | void suhosin_hook_post_handlers(TSRMLS_D); | 309 | void suhosin_hook_post_handlers(TSRMLS_D); |
| 310 | void suhosin_unhook_post_handlers(); | ||
| 310 | void suhosin_hook_register_server_variables(); | 311 | void suhosin_hook_register_server_variables(); |
| 311 | void suhosin_hook_header_handler(); | 312 | void suhosin_hook_header_handler(); |
| 312 | void suhosin_unhook_header_handler(); | 313 | void suhosin_unhook_header_handler(); |
diff --git a/post_handler.c b/post_handler.c index c36c1a0..c097a06 100644 --- a/post_handler.c +++ b/post_handler.c | |||
| @@ -79,6 +79,14 @@ last_value: | |||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static void suhosin_post_handler_modification(sapi_post_entry *spe) | ||
| 83 | { | ||
| 84 | char *content_type = estrndup(spe->content_type, spe->content_type_len); | ||
| 85 | suhosin_log(S_VARS, "some extension replaces the POST handler for %s - Suhosin's protection will be incomplete", content_type); | ||
| 86 | efree(content_type); | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
| 82 | /* {{{ php_post_entries[] | 90 | /* {{{ php_post_entries[] |
| 83 | */ | 91 | */ |
| 84 | static sapi_post_entry suhosin_post_entries[] = { | 92 | static sapi_post_entry suhosin_post_entries[] = { |
| @@ -90,6 +98,8 @@ static sapi_post_entry suhosin_post_entries[] = { | |||
| 90 | 98 | ||
| 91 | void suhosin_hook_post_handlers(TSRMLS_D) | 99 | void suhosin_hook_post_handlers(TSRMLS_D) |
| 92 | { | 100 | { |
| 101 | HashTable tempht; | ||
| 102 | |||
| 93 | #if PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0) | 103 | #if PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 0) |
| 94 | sapi_unregister_post_entry(&suhosin_post_entries[0] TSRMLS_CC); | 104 | sapi_unregister_post_entry(&suhosin_post_entries[0] TSRMLS_CC); |
| 95 | sapi_unregister_post_entry(&suhosin_post_entries[1] TSRMLS_CC); | 105 | sapi_unregister_post_entry(&suhosin_post_entries[1] TSRMLS_CC); |
| @@ -99,8 +109,21 @@ void suhosin_hook_post_handlers(TSRMLS_D) | |||
| 99 | sapi_unregister_post_entry(&suhosin_post_entries[1]); | 109 | sapi_unregister_post_entry(&suhosin_post_entries[1]); |
| 100 | sapi_register_post_entries(suhosin_post_entries); | 110 | sapi_register_post_entries(suhosin_post_entries); |
| 101 | #endif | 111 | #endif |
| 112 | /* we want to get notified if another extension deregisters the suhosin post handlers */ | ||
| 113 | |||
| 114 | /* we need to tell suhosin patch that there is a new valid destructor */ | ||
| 115 | /* therefore we have create HashTable that has this destructor */ | ||
| 116 | zend_hash_init(&tempht, 0, NULL, suhosin_post_handler_modification, 0); | ||
| 117 | zend_hash_destroy(&tempht); | ||
| 118 | /* And now we can overwrite the destructor for post entries */ | ||
| 119 | SG(known_post_content_types).pDestructor = suhosin_post_handler_modification; | ||
| 102 | } | 120 | } |
| 103 | 121 | ||
| 122 | void suhosin_unhook_post_handlers() | ||
| 123 | { | ||
| 124 | /* Restore to an empty destructor */ | ||
| 125 | SG(known_post_content_types).pDestructor = NULL; | ||
| 126 | } | ||
| 104 | 127 | ||
| 105 | /* | 128 | /* |
| 106 | * Local variables: | 129 | * Local variables: |
| @@ -191,6 +191,7 @@ static void suhosin_shutdown(zend_extension *extension) | |||
| 191 | { | 191 | { |
| 192 | suhosin_unhook_execute(); | 192 | suhosin_unhook_execute(); |
| 193 | suhosin_unhook_header_handler(); | 193 | suhosin_unhook_header_handler(); |
| 194 | suhosin_unhook_post_handlers(); | ||
| 194 | 195 | ||
| 195 | if (ze != NULL) { | 196 | if (ze != NULL) { |
| 196 | ze->startup = orig_module_startup; | 197 | ze->startup = orig_module_startup; |
