diff options
| author | Stefan Esser | 2012-01-14 18:40:39 +0100 |
|---|---|---|
| committer | Stefan Esser | 2012-01-14 18:40:39 +0100 |
| commit | baed654dfa7c0e04795307b6567d4141fd6365c3 (patch) | |
| tree | 3331290765f261825a708309a36632e2f0707bba /post_handler.c | |
| parent | 73b1968ee30f6d9d2dae497544b910e68e114bfa (diff) | |
detect runtime modification of post handlers
Diffstat (limited to 'post_handler.c')
| -rw-r--r-- | post_handler.c | 23 |
1 files changed, 23 insertions, 0 deletions
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: |
