mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6: Fixed bug #69111 (Crash in SessionHandler::read()). Made session save handler abuse much harder than before.
This commit is contained in:
commit
34ff7bbeb1
9 changed files with 104 additions and 7 deletions
|
@ -22,6 +22,10 @@
|
|||
#include "php_session.h"
|
||||
|
||||
#define PS_SANITY_CHECK \
|
||||
if (PS(session_status) != php_session_active) { \
|
||||
php_error_docref(NULL, E_WARNING, "Session is not active"); \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
if (PS(default_mod) == NULL) { \
|
||||
php_error_docref(NULL, E_CORE_ERROR, "Cannot call default session handler"); \
|
||||
RETURN_FALSE; \
|
||||
|
@ -40,6 +44,7 @@ PHP_METHOD(SessionHandler, open)
|
|||
{
|
||||
char *save_path = NULL, *session_name = NULL;
|
||||
size_t save_path_len, session_name_len;
|
||||
int ret;
|
||||
|
||||
PS_SANITY_CHECK;
|
||||
|
||||
|
@ -48,7 +53,15 @@ PHP_METHOD(SessionHandler, open)
|
|||
}
|
||||
|
||||
PS(mod_user_is_open) = 1;
|
||||
RETVAL_BOOL(SUCCESS == PS(default_mod)->s_open(&PS(mod_data), save_path, session_name));
|
||||
|
||||
zend_try {
|
||||
ret = PS(default_mod)->s_open(&PS(mod_data), save_path, session_name);
|
||||
} zend_catch {
|
||||
PS(session_status) = php_session_none;
|
||||
zend_bailout();
|
||||
} zend_end_try();
|
||||
|
||||
RETVAL_BOOL(SUCCESS == ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -56,6 +69,8 @@ PHP_METHOD(SessionHandler, open)
|
|||
Wraps the old close handler */
|
||||
PHP_METHOD(SessionHandler, close)
|
||||
{
|
||||
int ret;
|
||||
|
||||
PS_SANITY_CHECK_IS_OPEN;
|
||||
|
||||
// don't return on failure, since not closing the default handler
|
||||
|
@ -63,7 +78,15 @@ PHP_METHOD(SessionHandler, close)
|
|||
zend_parse_parameters_none();
|
||||
|
||||
PS(mod_user_is_open) = 0;
|
||||
RETVAL_BOOL(SUCCESS == PS(default_mod)->s_close(&PS(mod_data)));
|
||||
|
||||
zend_try {
|
||||
ret = PS(default_mod)->s_close(&PS(mod_data));
|
||||
} zend_catch {
|
||||
PS(session_status) = php_session_none;
|
||||
zend_bailout();
|
||||
} zend_end_try();
|
||||
|
||||
RETVAL_BOOL(SUCCESS == ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue