diff options
| author | Ben Fuhrmannek | 2015-01-15 17:09:32 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2015-01-15 17:09:32 +0100 |
| commit | 5335470004c0e97fd5f4d4a2d0371693cb26fccc (patch) | |
| tree | b058967648f7069b5f43a1c23a7c7b8f56460959 /session.c | |
| parent | 68960966324f4701a1f402e97f17ca7870a317a4 (diff) | |
removed <5.4 compatibility code
Diffstat (limited to 'session.c')
| -rw-r--r-- | session.c | 61 |
1 files changed, 0 insertions, 61 deletions
| @@ -58,22 +58,6 @@ static int suhosin_get_session_var(char *name, size_t namelen, zval ***state_var | |||
| 58 | 58 | ||
| 59 | if (SESSION_G(http_session_vars) && SESSION_G(http_session_vars)->type == IS_ARRAY) { | 59 | if (SESSION_G(http_session_vars) && SESSION_G(http_session_vars)->type == IS_ARRAY) { |
| 60 | ret = zend_hash_find(Z_ARRVAL_P(SESSION_G(http_session_vars)), name, namelen + 1, (void **) state_var); | 60 | ret = zend_hash_find(Z_ARRVAL_P(SESSION_G(http_session_vars)), name, namelen + 1, (void **) state_var); |
| 61 | |||
| 62 | #if 0 //PHP_VERSION_ID < 50400 | ||
| 63 | /* If register_globals is enabled, and | ||
| 64 | * if there is an entry for the slot in $_SESSION, and | ||
| 65 | * if that entry is still set to NULL, and | ||
| 66 | * if the global var exists, then | ||
| 67 | * we prefer the same key in the global sym table. */ | ||
| 68 | |||
| 69 | if (PG(register_globals) && ret == SUCCESS && Z_TYPE_PP(*state_var) == IS_NULL) { | ||
| 70 | zval **tmp; | ||
| 71 | |||
| 72 | if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void **) &tmp) == SUCCESS) { | ||
| 73 | *state_var = tmp; | ||
| 74 | } | ||
| 75 | } | ||
| 76 | #endif | ||
| 77 | } | 61 | } |
| 78 | return ret; | 62 | return ret; |
| 79 | } | 63 | } |
| @@ -123,7 +107,6 @@ static void suhosin_send_cookie(TSRMLS_D) | |||
| 123 | 107 | ||
| 124 | /* The following is requires to be 100% compatible to PHP | 108 | /* The following is requires to be 100% compatible to PHP |
| 125 | versions where the hash extension is not available by default */ | 109 | versions where the hash extension is not available by default */ |
| 126 | #if 1 //(PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3) | ||
| 127 | if (zend_hash_find(EG(ini_directives), "session.hash_bits_per_character", sizeof("session.hash_bits_per_character"), (void **) &ini_entry) == SUCCESS) { | 110 | if (zend_hash_find(EG(ini_directives), "session.hash_bits_per_character", sizeof("session.hash_bits_per_character"), (void **) &ini_entry) == SUCCESS) { |
| 128 | #ifndef ZTS | 111 | #ifndef ZTS |
| 129 | base = (char *) ini_entry->mh_arg2; | 112 | base = (char *) ini_entry->mh_arg2; |
| @@ -132,7 +115,6 @@ static void suhosin_send_cookie(TSRMLS_D) | |||
| 132 | #endif | 115 | #endif |
| 133 | session_send_cookie = (int *) (base+(size_t) ini_entry->mh_arg1+sizeof(long)); | 116 | session_send_cookie = (int *) (base+(size_t) ini_entry->mh_arg1+sizeof(long)); |
| 134 | } | 117 | } |
| 135 | #endif | ||
| 136 | *session_send_cookie = 1; | 118 | *session_send_cookie = 1; |
| 137 | } | 119 | } |
| 138 | 120 | ||
| @@ -155,9 +137,7 @@ static int suhosin_hook_s_read(void **mod_data, const char *key, char **val, int | |||
| 155 | /* protect dumb session handlers */ | 137 | /* protect dumb session handlers */ |
| 156 | if (key == NULL || !key[0] || | 138 | if (key == NULL || !key[0] || |
| 157 | (*mod_data == NULL | 139 | (*mod_data == NULL |
| 158 | #if 1 //PHP_VERSION_ID >= 50400 | ||
| 159 | && !SESSION_G(mod_user_implemented) | 140 | && !SESSION_G(mod_user_implemented) |
| 160 | #endif | ||
| 161 | )) { | 141 | )) { |
| 162 | regenerate: | 142 | regenerate: |
| 163 | SDEBUG("regenerating key is %s", key); | 143 | SDEBUG("regenerating key is %s", key); |
| @@ -169,14 +149,6 @@ regenerate: | |||
| 169 | goto regenerate; | 149 | goto regenerate; |
| 170 | } | 150 | } |
| 171 | } | 151 | } |
| 172 | #if 0 //(PHP_MAJOR_VERSION < 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2) | ||
| 173 | else if (strpbrk(KEY, "\r\n\t <>'\"\\")) { | ||
| 174 | suhosin_log(S_SESSION, "session id ('%s') contains invalid chars - regenerating", KEY); | ||
| 175 | if (!SUHOSIN_G(simulation)) { | ||
| 176 | goto regenerate; | ||
| 177 | } | ||
| 178 | } | ||
| 179 | #endif | ||
| 180 | 152 | ||
| 181 | r = SUHOSIN_G(old_s_read)(mod_data, KEY, val, vallen TSRMLS_CC); | 153 | r = SUHOSIN_G(old_s_read)(mod_data, KEY, val, vallen TSRMLS_CC); |
| 182 | 154 | ||
| @@ -209,9 +181,7 @@ static int suhosin_hook_s_write(void **mod_data, const char *key, const char *va | |||
| 209 | /* protect dumb session handlers */ | 181 | /* protect dumb session handlers */ |
| 210 | if (key == NULL || !key[0] || val == NULL || strlen(key) > SUHOSIN_G(session_max_id_length) || | 182 | if (key == NULL || !key[0] || val == NULL || strlen(key) > SUHOSIN_G(session_max_id_length) || |
| 211 | (*mod_data == NULL | 183 | (*mod_data == NULL |
| 212 | #if 1 //PHP_VERSION_ID >= 50400 | ||
| 213 | && !SESSION_G(mod_user_implemented) | 184 | && !SESSION_G(mod_user_implemented) |
| 214 | #endif | ||
| 215 | )) { | 185 | )) { |
| 216 | r = FAILURE; | 186 | r = FAILURE; |
| 217 | goto return_write; | 187 | goto return_write; |
| @@ -257,9 +227,7 @@ static int suhosin_hook_s_destroy(void **mod_data, const char *key TSRMLS_DC) | |||
| 257 | /* protect dumb session handlers */ | 227 | /* protect dumb session handlers */ |
| 258 | if (key == NULL || !key[0] || strlen(key) > SUHOSIN_G(session_max_id_length) || | 228 | if (key == NULL || !key[0] || strlen(key) > SUHOSIN_G(session_max_id_length) || |
| 259 | (*mod_data == NULL | 229 | (*mod_data == NULL |
| 260 | #if 1 //PHP_VERSION_ID >= 50400 | ||
| 261 | && !SESSION_G(mod_user_implemented) | 230 | && !SESSION_G(mod_user_implemented) |
| 262 | #endif | ||
| 263 | )) { | 231 | )) { |
| 264 | return FAILURE; | 232 | return FAILURE; |
| 265 | } | 233 | } |
| @@ -343,7 +311,6 @@ void suhosin_hook_session(TSRMLS_D) | |||
| 343 | return; | 311 | return; |
| 344 | } | 312 | } |
| 345 | /* retrieve globals from module entry struct if possible */ | 313 | /* retrieve globals from module entry struct if possible */ |
| 346 | #if 1 //PHP_VERSION_ID >= 50200 | ||
| 347 | #ifdef ZTS | 314 | #ifdef ZTS |
| 348 | if (session_globals_id == 0) { | 315 | if (session_globals_id == 0) { |
| 349 | session_globals_id = *module->globals_id_ptr; | 316 | session_globals_id = *module->globals_id_ptr; |
| @@ -353,32 +320,6 @@ void suhosin_hook_session(TSRMLS_D) | |||
| 353 | session_globals = module->globals_ptr; | 320 | session_globals = module->globals_ptr; |
| 354 | } | 321 | } |
| 355 | #endif | 322 | #endif |
| 356 | #else | ||
| 357 | /* retrieve globals from symbols if PHP version is old */ | ||
| 358 | #ifdef ZTS | ||
| 359 | if (session_globals_id == 0) { | ||
| 360 | ps_globals_id_ptr = DL_FETCH_SYMBOL(module->handle, "ps_globals_id"); | ||
| 361 | if (ps_globals_id_ptr == NULL) { | ||
| 362 | ps_globals_id_ptr = DL_FETCH_SYMBOL(module->handle, "_ps_globals_id"); | ||
| 363 | } | ||
| 364 | if (ps_globals_id_ptr == NULL) { | ||
| 365 | return; | ||
| 366 | } | ||
| 367 | |||
| 368 | session_globals_id = *ps_globals_id_ptr; | ||
| 369 | } | ||
| 370 | #else | ||
| 371 | if (session_globals == NULL) { | ||
| 372 | session_globals = DL_FETCH_SYMBOL(module->handle, "ps_globals"); | ||
| 373 | if (session_globals == NULL) { | ||
| 374 | session_globals = DL_FETCH_SYMBOL(module->handle, "_ps_globals"); | ||
| 375 | } | ||
| 376 | if (session_globals == NULL) { | ||
| 377 | return; | ||
| 378 | } | ||
| 379 | } | ||
| 380 | #endif | ||
| 381 | #endif | ||
| 382 | 323 | ||
| 383 | if (old_OnUpdateSaveHandler != NULL) { | 324 | if (old_OnUpdateSaveHandler != NULL) { |
| 384 | return; | 325 | return; |
| @@ -401,12 +342,10 @@ void suhosin_hook_session(TSRMLS_D) | |||
| 401 | suhosin_hook_session_module(TSRMLS_C); | 342 | suhosin_hook_session_module(TSRMLS_C); |
| 402 | 343 | ||
| 403 | /* Protect the PHP serializer from ! attacks */ | 344 | /* Protect the PHP serializer from ! attacks */ |
| 404 | #if 1 //PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 2) | ||
| 405 | serializer = (ps_serializer *) SESSION_G(serializer); | 345 | serializer = (ps_serializer *) SESSION_G(serializer); |
| 406 | if (serializer != NULL && strcmp(serializer->name, "php")==0) { | 346 | if (serializer != NULL && strcmp(serializer->name, "php")==0) { |
| 407 | serializer->encode = suhosin_session_encode; | 347 | serializer->encode = suhosin_session_encode; |
| 408 | } | 348 | } |
| 409 | #endif | ||
| 410 | 349 | ||
| 411 | /* increase session identifier entropy */ | 350 | /* increase session identifier entropy */ |
| 412 | if (SESSION_G(entropy_length) == 0 || SESSION_G(entropy_file) == NULL) { | 351 | if (SESSION_G(entropy_length) == 0 || SESSION_G(entropy_file) == NULL) { |
