summaryrefslogtreecommitdiff
path: root/post_handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'post_handler.c')
-rw-r--r--post_handler.c23
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
82static 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 */
84static sapi_post_entry suhosin_post_entries[] = { 92static sapi_post_entry suhosin_post_entries[] = {
@@ -90,6 +98,8 @@ static sapi_post_entry suhosin_post_entries[] = {
90 98
91void suhosin_hook_post_handlers(TSRMLS_D) 99void 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
122void 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: