Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/PHP-7.0.3' into PHP-7.0.3
Browse files Browse the repository at this point in the history
* origin/PHP-7.0.3:
  fix tests
  fix wrong gc sequence
  revert the API string as well
  update NEWS
  Revert "Fix #70720"
  sync NEWS
  reset ext/session to the state of 7.0.2
  improve fix for bug #71201
  set versions to 7.0.3RC1
  fix test for 7.0, OpenSSL >= 1.0.2 disables SSLv2 by default
  fork test
  fix test
  fork test
  fork test for win32
  fork test
  Use SUCCESS/FAILURE
  Fixed bug #65720 ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c:281: bad if test
  Fixed bug #65720 ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c:281: bad if test
  Update NEWS
  Fixed bug 71397 (mb_send_mail segmentation fault)
  • Loading branch information
smalyshev committed Feb 2, 2016
2 parents 33b1fbb + 6ba7ace commit 877823e
Show file tree
Hide file tree
Showing 44 changed files with 327 additions and 301 deletions.
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=7
PHP_MINOR_VERSION=0
PHP_RELEASE_VERSION=3
PHP_EXTRA_VERSION="-dev"
PHP_EXTRA_VERSION="RC1"
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`

Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/libmbfl/filters/mbfilter_cp5022x.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ mbfl_filt_conv_jis_ms_wchar(int c, mbfl_convert_filter *filter)
w = cp932ext1_ucs_table[s - cp932ext1_ucs_table_min];
} else if (s >= cp932ext2_ucs_table_min && s < cp932ext2_ucs_table_max) {
w = cp932ext2_ucs_table[s - cp932ext2_ucs_table_min];
} else if (s >= cp932ext3_ucs_table_min && s < cp932ext2_ucs_table_max) {
} else if (s >= cp932ext3_ucs_table_min && s < cp932ext3_ucs_table_max) {
w = cp932ext3_ucs_table[s - cp932ext3_ucs_table_min];
} else if (s >= 94 * 94 && s < 114 * 94) {
/* user-defined => PUA (Microsoft extended) */
Expand Down
1 change: 1 addition & 0 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -4148,6 +4148,7 @@ PHP_FUNCTION(mb_send_mail)
if ((s = zend_hash_str_find(&ht_headers, "CONTENT-TRANSFER-ENCODING", sizeof("CONTENT-TRANSFER-ENCODING") - 1))) {
enum mbfl_no_encoding _body_enc;

ZEND_ASSERT(Z_TYPE_P(s) == IS_STRING);
_body_enc = mbfl_name2no_encoding(Z_STRVAL_P(s));
switch (_body_enc) {
case mbfl_no_encoding_base64:
Expand Down
11 changes: 1 addition & 10 deletions ext/session/mod_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ PS_OPEN_FUNC(user)
ZVAL_STRING(&args[0], (char*)save_path);
ZVAL_STRING(&args[1], (char*)session_name);

zend_try {
ps_call_handler(&PSF(open), 2, args, &retval);
} zend_catch {
PS(session_status) = php_session_none;
if (!Z_ISUNDEF(retval)) {
zval_ptr_dtor(&retval);
}
zend_bailout();
} zend_end_try();

ps_call_handler(&PSF(open), 2, args, &retval);
PS(mod_user_implemented) = 1;

FINISH;
Expand Down
27 changes: 2 additions & 25 deletions ext/session/mod_user_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
#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; \
Expand All @@ -44,7 +40,6 @@ PHP_METHOD(SessionHandler, open)
{
char *save_path = NULL, *session_name = NULL;
size_t save_path_len, session_name_len;
int ret;

PS_SANITY_CHECK;

Expand All @@ -53,40 +48,22 @@ PHP_METHOD(SessionHandler, open)
}

PS(mod_user_is_open) = 1;

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);
RETVAL_BOOL(SUCCESS == PS(default_mod)->s_open(&PS(mod_data), save_path, session_name));
}
/* }}} */

/* {{{ proto bool SessionHandler::close()
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
// could result in memory leaks or other nasties
zend_parse_parameters_none();

PS(mod_user_is_open) = 0;

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);
RETVAL_BOOL(SUCCESS == PS(default_mod)->s_close(&PS(mod_data)));
}
/* }}} */

Expand Down
52 changes: 20 additions & 32 deletions ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@ zend_class_entry *php_session_update_timestamp_iface_entry;
#define APPLY_TRANS_SID (PS(use_trans_sid) && !PS(use_only_cookies))

static void php_session_send_cookie(void);
static void php_session_abort(void);

/* Dispatched by RINIT and by php_session_destroy */
static inline void php_rinit_session_globals(void) /* {{{ */
{
/* Do NOT init PS(mod_user_names) here! */
/* TODO: These could be moved to MINIT and removed. These should be initialized by php_rshutdown_session_globals() always when execution is finished. */
PS(id) = NULL;
PS(session_status) = php_session_none;
PS(mod_data) = NULL;
Expand Down Expand Up @@ -131,15 +129,10 @@ static inline void php_rshutdown_session_globals(void) /* {{{ */
zend_string_release(PS(id));
PS(id) = NULL;
}

if (PS(session_vars)) {
zend_string_release(PS(session_vars));
PS(session_vars) = NULL;
}

/* User save handlers may end up directly here by misuse, bugs in user script, etc. */
/* Set session status to prevent error while restoring save handler INI value. */
PS(session_status) = php_session_none;
}
/* }}} */

Expand Down Expand Up @@ -510,10 +503,7 @@ static void php_session_initialize(void) /* {{{ */
{
zend_string *val = NULL;

PS(session_status) = php_session_active;

if (!PS(mod)) {
PS(session_status) = php_session_disabled;
php_error_docref(NULL, E_ERROR, "No storage module chosen - failed to initialize session");
return;
}
Expand All @@ -522,19 +512,14 @@ static void php_session_initialize(void) /* {{{ */
if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name)) == FAILURE
/* || PS(mod_data) == NULL */ /* FIXME: open must set valid PS(mod_data) with success */
) {
php_session_abort();
php_error_docref(NULL, E_ERROR, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path));
return;
}

/* If there is no ID, use session module to create one */
if (!PS(id) || !ZSTR_VAL(PS(id))[0]) {
if (PS(id)) {
zend_string_release(PS(id));
}
if (!PS(id)) {
PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
if (!PS(id)) {
php_session_abort();
php_error_docref(NULL, E_ERROR, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
return;
}
Expand All @@ -556,19 +541,21 @@ static void php_session_initialize(void) /* {{{ */
}

php_session_reset_id();

/* GC must be done before read */
php_session_gc();
PS(session_status) = php_session_active;

/* Read data */
php_session_track_init();
if (PS(mod)->s_read(&PS(mod_data), PS(id), &val, PS(gc_maxlifetime)) == FAILURE) {
php_session_abort();
/* Some broken save handler implementation returns FAILURE for non-existent session ID */
/* It's better to raise error for this, but disabled error for better compatibility */
php_error_docref(NULL, E_WARNING, "Failed to read session data: %s (path: %s)", PS(mod)->s_name, PS(save_path));
return;
/*
php_error_docref(NULL, E_NOTICE, "Failed to read session data: %s (path: %s)", PS(mod)->s_name, PS(save_path));
*/
}

/* GC must be done after read */
php_session_gc();

if (PS(session_vars)) {
zend_string_release(PS(session_vars));
PS(session_vars) = NULL;
Expand Down Expand Up @@ -1302,13 +1289,11 @@ static int php_session_cache_limiter(void) /* {{{ */
php_session_cache_limiter_t *lim;

if (PS(cache_limiter)[0] == '\0') return 0;
if (PS(session_status) != php_session_active) return -1;

if (SG(headers_sent)) {
const char *output_start_filename = php_output_get_start_filename();
int output_start_lineno = php_output_get_start_lineno();

php_session_abort();
if (output_start_filename) {
php_error_docref(NULL, E_WARNING, "Cannot send session cache limiter - headers already sent (output started at %s:%d)", output_start_filename, output_start_lineno);
} else {
Expand Down Expand Up @@ -1668,19 +1653,19 @@ PHPAPI void php_session_start(void) /* {{{ */
static void php_session_flush(int write) /* {{{ */
{
if (PS(session_status) == php_session_active) {
php_session_save_current_state(write);
PS(session_status) = php_session_none;
php_session_save_current_state(write);
}
}
/* }}} */

static void php_session_abort(void) /* {{{ */
{
if (PS(session_status) == php_session_active) {
PS(session_status) = php_session_none;
if (PS(mod_data) || PS(mod_user_implemented)) {
PS(mod)->s_close(&PS(mod_data));
}
PS(session_status) = php_session_none;
}
}
/* }}} */
Expand Down Expand Up @@ -2055,13 +2040,13 @@ static PHP_FUNCTION(session_regenerate_id)
return;
}

if (PS(session_status) != php_session_active) {
php_error_docref(NULL, E_WARNING, "Cannot regenerate session id - session is not active");
if (SG(headers_sent) && PS(use_cookies)) {
php_error_docref(NULL, E_WARNING, "Cannot regenerate session id - headers already sent");
RETURN_FALSE;
}

if (SG(headers_sent) && PS(use_cookies)) {
php_error_docref(NULL, E_WARNING, "Cannot regenerate session id - headers already sent");
if (PS(session_status) != php_session_active) {
php_error_docref(NULL, E_WARNING, "Cannot regenerate session id - session is not active");
RETURN_FALSE;
}

Expand Down Expand Up @@ -2113,15 +2098,13 @@ static PHP_FUNCTION(session_regenerate_id)
zend_string_release(PS(id));
PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
if (!PS(id)) {
PS(mod)->s_close(&PS(mod_data));
PS(session_status) = php_session_none;
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Failed to create session ID by collision: %s (path: %s)", PS(mod)->s_name, PS(save_path));
RETURN_FALSE;
}
}
/* Read is required to make new session data at this point. */
if (PS(mod)->s_read(&PS(mod_data), PS(id), &data, PS(gc_maxlifetime)) == FAILURE) {
PS(mod)->s_close(&PS(mod_data));
PS(session_status) = php_session_none;
php_error_docref(NULL, E_RECOVERABLE_ERROR, "Failed to create(read) session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
RETURN_FALSE;
Expand Down Expand Up @@ -2293,6 +2276,11 @@ static PHP_FUNCTION(session_start)
RETURN_FALSE;
}

if (PS(id) && !(ZSTR_LEN(PS(id)))) {
php_error_docref(NULL, E_WARNING, "Cannot start session with empty session ID");
RETURN_FALSE;
}

/* set options */
if (options) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(options), num_idx, str_idx, value) {
Expand Down
2 changes: 1 addition & 1 deletion ext/session/tests/016.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ session_write_close();
print "I live\n";
?>
--EXPECTF--
Warning: session_start(): Failed to read session data: files (path: 123;:/really%scompletely:::/invalid;;,23123;213) in %s on line %d
Warning: session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (123;:/really%scompletely:::/invalid;;,23123;213) in %s on line %d
I live
6 changes: 3 additions & 3 deletions ext/session/tests/bug32330.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ $_SESSION['E'] = 'F';
?>
--EXPECTF--
open: path = /tmp, name = sid
gc: maxlifetime = %d
read: id = %s
gc: maxlifetime = %d
write: id = %s, data = A|s:1:"B";
close
open: path = /tmp, name = sid
gc: maxlifetime = %d
read: id = %s
gc: maxlifetime = %d
destroy: id = %s
close
open: path = /tmp, name = sid
gc: maxlifetime = %d
read: id = %s
gc: maxlifetime = %d
write: id = %s, data = E|s:1:"F";
close
2 changes: 1 addition & 1 deletion ext/session/tests/bug55688.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ $x = new SessionHandler;
$x->gc(1);
?>
--EXPECTF--
Warning: SessionHandler::gc(): Session is not active in %s on line %d
Warning: SessionHandler::gc(): Parent session handler is not open in %s on line %d
9 changes: 0 additions & 9 deletions ext/session/tests/bug60634.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,8 @@ session_start();
session_write_close();
echo "um, hi\n";

/*
FIXME: Since session module try to write/close session data in
RSHUTDOWN, write() is executed twices. This is caused by undefined
function error and zend_bailout(). Current session module codes
depends on this behavior. These codes should be modified to remove
multiple write().
*/

?>
--EXPECTF--
write: goodbye cruel world
write: goodbye cruel world
close: goodbye cruel world

6 changes: 0 additions & 6 deletions ext/session/tests/bug60634_error_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ session_start();
session_write_close();
echo "um, hi\n";

/*
FIXME: Something wrong. It should try to close after error, otherwise session
may keep "open" state.
*/

?>
--EXPECTF--
write: goodbye cruel world
Expand All @@ -56,4 +51,3 @@ Stack trace:
#1 %s(%d): session_write_close()
#2 {main}
thrown in %s on line %d

30 changes: 14 additions & 16 deletions ext/session/tests/bug61728.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,32 @@ function output_html($ext) {
return strlen($ext);
}

function open ($save_path, $session_name) {
function open ($save_path, $session_name) {
return true;
}
}

function close() {
function close() {
return true;
}
}

function read ($id) {
return '';
}
function read ($id) {
}

function write ($id, $sess_data) {
function write ($id, $sess_data) {
ob_start("output_html");
echo "laruence";
ob_end_flush();
return true;
}
}

function destroy ($id) {
return true;
}
function destroy ($id) {
}

function gc ($maxlifetime) {
return true;
}
function gc ($maxlifetime) {
return true;
}

session_set_save_handler ("open", "close", "read", "write", "destroy", "gc");
session_set_save_handler ("open", "close", "read", "write", "destroy", "gc");
session_start();
--EXPECTF--
8
Loading

0 comments on commit 877823e

Please sign in to comment.