[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
tony2001Sun May 22 08:59:30 2005 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: fix compile warning http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.52r2=1.336.2.53ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.52 php-src/ext/session/session.c:1.336.2.53 --- php-src/ext/session/session.c:1.336.2.52Sat May 21 15:46:34 2005 +++ php-src/ext/session/session.c Sun May 22 08:59:29 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.52 2005/05/21 19:46:34 rasmus Exp $ */ +/* $Id: session.c,v 1.336.2.53 2005/05/22 12:59:29 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -129,6 +129,7 @@ } } OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + return SUCCESS; } /* {{{ PHP_INI -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sniper Sun Feb 13 12:51:33 2005 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: - Added the alias session_commit() (more intuitive name for session_write_close()) MFH: - Partial sync of the file by adding macro SESSION_CHECK_ACTIVE_STATE http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.49r2=1.336.2.50ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.49 php-src/ext/session/session.c:1.336.2.50 --- php-src/ext/session/session.c:1.336.2.49Fri Jan 21 11:04:54 2005 +++ php-src/ext/session/session.c Sun Feb 13 12:51:32 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.49 2005/01/21 16:04:54 sesser Exp $ */ +/* $Id: session.c,v 1.336.2.50 2005/02/13 17:51:32 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -75,6 +75,7 @@ PHP_FE(session_set_cookie_params, NULL) PHP_FE(session_get_cookie_params, NULL) PHP_FE(session_write_close, NULL) + PHP_FALIAS(session_commit, session_write_close, NULL) {NULL, NULL, NULL} }; /* }}} */ @@ -84,12 +85,16 @@ static ps_module *_php_find_ps_module(char *name TSRMLS_DC); static const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC); +#define SESSION_CHECK_ACTIVE_STATE \ + if (PS(session_status) == php_session_active) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, A session is active. You cannot change the session module's ini settings at this time.); \ + return FAILURE; \ + } + static PHP_INI_MH(OnUpdateSaveHandler) { - if (PS(session_status) == php_session_active) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, A session is active. You cannot change the session module's ini settings at this time.); - return FAILURE; - } + SESSION_CHECK_ACTIVE_STATE; + PS(mod) = _php_find_ps_module(new_value TSRMLS_CC); if (PG(modules_activated) !PS(mod)) { @@ -101,10 +106,8 @@ static PHP_INI_MH(OnUpdateSerializer) { - if (PS(session_status) == php_session_active) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, A session is active. You cannot change the session module's ini settings at this time.); - return FAILURE; - } + SESSION_CHECK_ACTIVE_STATE; + PS(serializer) = _php_find_ps_serializer(new_value TSRMLS_CC); if (PG(modules_activated) !PS(serializer)) { @@ -511,8 +514,7 @@ zval *session_vars = NULL; /* Unconditionally destroy existing arrays -- possible dirty data */ - zend_hash_del(EG(symbol_table), HTTP_SESSION_VARS, - sizeof(HTTP_SESSION_VARS)); + zend_hash_del(EG(symbol_table), HTTP_SESSION_VARS, sizeof(HTTP_SESSION_VARS)); zend_hash_del(EG(symbol_table), _SESSION, sizeof(_SESSION)); MAKE_STD_ZVAL(session_vars); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sesser Fri Jan 21 11:04:54 2005 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.48r2=1.336.2.49ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.48 php-src/ext/session/session.c:1.336.2.49 --- php-src/ext/session/session.c:1.336.2.48Sun Jan 9 12:57:50 2005 +++ php-src/ext/session/session.c Fri Jan 21 11:04:54 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.48 2005/01/09 17:57:50 tony2001 Exp $ */ +/* $Id: session.c,v 1.336.2.49 2005/01/21 16:04:54 sesser Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -408,7 +408,7 @@ p += namelen + 1; if (has_value) { - MAKE_STD_ZVAL(current); + ALLOC_INIT_ZVAL(current); if (php_var_unserialize(current, (const unsigned char **)p, endptr, var_hash TSRMLS_CC)) { php_set_session_var(name, namelen, current, var_hash TSRMLS_CC); } @@ -488,7 +488,7 @@ q++; if (has_value) { - MAKE_STD_ZVAL(current); + ALLOC_INIT_ZVAL(current); if (php_var_unserialize(current, (const unsigned char **)q, endptr, var_hash TSRMLS_CC)) { php_set_session_var(name, namelen, current, var_hash TSRMLS_CC); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
tony2001Sun Jan 9 12:57:51 2005 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: fix bug #31454 http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.47r2=1.336.2.48ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.47 php-src/ext/session/session.c:1.336.2.48 --- php-src/ext/session/session.c:1.336.2.47Thu Dec 9 12:16:57 2004 +++ php-src/ext/session/session.c Sun Jan 9 12:57:50 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.47 2004/12/09 17:16:57 tony2001 Exp $ */ +/* $Id: session.c,v 1.336.2.48 2005/01/09 17:57:50 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1246,13 +1246,23 @@ zval **args[6]; int i; ps_user *mdata; + char *name; if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_array_ex(6, args) == FAILURE) WRONG_PARAM_COUNT; if (PS(session_status) != php_session_none) RETURN_FALSE; - + + for (i = 0; i 6; i++) { + if (!zend_is_callable(*args[i], 0, name)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Argument %d is not a valid callback, i+1); + efree(name); + RETURN_FALSE; + } + efree(name); + } + zend_alter_ini_entry(session.save_handler, sizeof(session.save_handler), user, sizeof(user)-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); mdata = emalloc(sizeof(*mdata)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
tony2001Thu Dec 9 09:21:13 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: fix segfault in session_module_name() when session.save_handler is empty http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.45r2=1.336.2.46ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.45 php-src/ext/session/session.c:1.336.2.46 --- php-src/ext/session/session.c:1.336.2.45Tue Dec 7 09:01:56 2004 +++ php-src/ext/session/session.c Thu Dec 9 09:21:13 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.45 2004/12/07 14:01:56 tony2001 Exp $ */ +/* $Id: session.c,v 1.336.2.46 2004/12/09 14:21:13 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1222,11 +1222,21 @@ } PS(mod_data) = NULL; - RETVAL_STRING(safe_estrdup(PS(mod)-s_name), 0); - + if (PS(mod) PS(mod)-s_name) { + RETVAL_STRING(safe_estrdup(PS(mod)-s_name), 0); + } + else { + RETVAL_EMPTY_STRING(); + } + zend_alter_ini_entry(session.save_handler, sizeof(session.save_handler), Z_STRVAL_PP(p_name), Z_STRLEN_PP(p_name), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } else { - RETURN_STRING(safe_estrdup(PS(mod)-s_name), 0); + if (PS(mod) PS(mod)-s_name) { + RETURN_STRING(safe_estrdup(PS(mod)-s_name), 0); + } + else { + RETURN_EMPTY_STRING(); + } } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
tony2001Thu Dec 9 12:16:58 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: CS changes http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.46r2=1.336.2.47ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.46 php-src/ext/session/session.c:1.336.2.47 --- php-src/ext/session/session.c:1.336.2.46Thu Dec 9 09:21:13 2004 +++ php-src/ext/session/session.c Thu Dec 9 12:16:57 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.46 2004/12/09 14:21:13 tony2001 Exp $ */ +/* $Id: session.c,v 1.336.2.47 2004/12/09 17:16:57 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1224,8 +1224,7 @@ if (PS(mod) PS(mod)-s_name) { RETVAL_STRING(safe_estrdup(PS(mod)-s_name), 0); - } - else { + } else { RETVAL_EMPTY_STRING(); } @@ -1233,8 +1232,7 @@ } else { if (PS(mod) PS(mod)-s_name) { RETURN_STRING(safe_estrdup(PS(mod)-s_name), 0); - } - else { + } else { RETURN_EMPTY_STRING(); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
tony2001Thu Sep 30 10:18:25 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: fix segfaults and bug #30282 and suppress compile warnings http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.42r2=1.336.2.43ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.42 php-src/ext/session/session.c:1.336.2.43 --- php-src/ext/session/session.c:1.336.2.42Thu Sep 2 20:53:46 2004 +++ php-src/ext/session/session.c Thu Sep 30 10:18:25 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.42 2004/09/03 00:53:46 iliaa Exp $ */ +/* $Id: session.c,v 1.336.2.43 2004/09/30 14:18:25 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -409,7 +409,7 @@ if (has_value) { MAKE_STD_ZVAL(current); - if (php_var_unserialize(current, p, endptr, var_hash TSRMLS_CC)) { + if (php_var_unserialize(current, (const unsigned char **)p, endptr, var_hash TSRMLS_CC)) { php_set_session_var(name, namelen, current, var_hash TSRMLS_CC); } zval_ptr_dtor(current); @@ -489,7 +489,7 @@ if (has_value) { MAKE_STD_ZVAL(current); - if (php_var_unserialize(current, q, endptr, var_hash TSRMLS_CC)) { + if (php_var_unserialize(current, (const unsigned char **)q, endptr, var_hash TSRMLS_CC)) { php_set_session_var(name, namelen, current, var_hash TSRMLS_CC); } zval_ptr_dtor(current); @@ -528,7 +528,11 @@ char *ret = NULL; IF_SESSION_VARS() { - if (PS(serializer)-encode(ret, newlen TSRMLS_CC) == FAILURE) + if (!PS(serializer)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown session.serialize_handler. Failed to encode session object.); + ret = NULL; + } + else if (PS(serializer)-encode(ret, newlen TSRMLS_CC) == FAILURE) ret = NULL; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot encode non-existent session.); @@ -539,6 +543,10 @@ static void php_session_decode(const char *val, int vallen TSRMLS_DC) { + if (!PS(serializer)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Unknown session.serialize_handler. Failed to decode session object.); + return; + } if (PS(serializer)-decode(val, vallen TSRMLS_CC) == FAILURE) { php_session_destroy(TSRMLS_C); php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to decode session object. Session has been destroyed.); @@ -977,6 +985,21 @@ PS(define_sid) = 1; PS(send_cookie) = 1; if (PS(session_status) != php_session_none) { + + if (PS(session_status) == php_session_disabled) { + char *value; + + value = zend_ini_string(session.save_handler, sizeof(session.save_handler), 0); + + if (value) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot find save handler %s, value); + } + else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot find unknown save handler); + } + return; + } + php_error(E_NOTICE, A session had already been started - ignoring session_start()); return; } @@ -1386,9 +1409,15 @@ WRONG_PARAM_COUNT; } - if (PS(session_status) == php_session_none) + if (PS(session_status) == php_session_none || PS(session_status) == php_session_disabled) { php_session_start(TSRMLS_C); + } + if (PS(session_status) == php_session_disabled) { + efree(args); + RETURN_FALSE; + } + for (i = 0; i argc; i++) { if (Z_TYPE_PP(args[i]) == IS_ARRAY) SEPARATE_ZVAL(args[i]); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
Hello, this seems rather old commit anyway, may I ask why this is not merged into php-5 trees? I think without this, some scripts will misbehave in php 5. for instance: (php.ini) ...snip... session.use_cookies = 1 session.cookie_lifetime = 0 ...snip... (foo.php) if (!empty($_COOKIE[$session_name])) { // simply restoring session session_start(); } else { // set application dependent cookie params like this session_set_cookie_params($lifetime); session_start(); } in this case, first time we can set cookie with the arbitary lifetime however, as of 2nd time all those settings are overridden by php.ini settinngs. best regards, Masaki Fujimoto The Message From Sascha Schumann on Wed, 23 Jun 2004 16:29:17 -: sas Wed Jun 23 12:29:17 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/session session.c Log: - fix logic. if the client already sent us the cookie, we don't need to send it again. if the id has been changed, we need to update the client side. http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.39r2=1.336.2.40ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.39 php-src/ext/session/session.c:1.336.2.40 --- php-src/ext/session/session.c:1.336.2.39 Sat May 8 02:01:11 2004 +++ php-src/ext/session/session.c Wed Jun 23 12:29:16 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.39 2004/05/08 06:01:11 pollita Exp $ */ +/* $Id: session.c,v 1.336.2.40 2004/06/23 16:29:16 sas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -930,8 +930,9 @@ { int module_number = PS(module_number); - if (PS(use_cookies)) { + if (PS(use_cookies) PS(send_cookie)) { php_session_send_cookie(TSRMLS_C); + PS(send_cookie) = 0; } /* if the SID constant exists, destroy it. */ @@ -1283,6 +1284,7 @@ PS(id) = PS(mod)-s_create_sid(PS(mod_data), NULL TSRMLS_CC); + PS(send_cookie) = 1; php_session_reset_id(TSRMLS_C); RETURN_TRUE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Masaki Fujimoto [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
iliaa Thu Sep 2 20:53:47 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: Fixed bug #29925 (Added a check to prevent illegal characters in session key). http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.41r2=1.336.2.42ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.41 php-src/ext/session/session.c:1.336.2.42 --- php-src/ext/session/session.c:1.336.2.41Wed Jul 21 12:25:27 2004 +++ php-src/ext/session/session.c Thu Sep 2 20:53:46 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.41 2004/07/21 16:25:27 sesser Exp $ */ +/* $Id: session.c,v 1.336.2.42 2004/09/03 00:53:46 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -436,6 +436,11 @@ PS_ENCODE_LOOP( smart_str_appendl(buf, key, (unsigned char) key_length); + if (memchr(key, PS_DELIMITER, key_length)) { + PHP_VAR_SERIALIZE_DESTROY(var_hash); + smart_str_free(buf); + return FAILURE; + } smart_str_appendc(buf, PS_DELIMITER); php_var_serialize(buf, struc, var_hash TSRMLS_CC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sas Wed Jun 23 12:29:17 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: - fix logic. if the client already sent us the cookie, we don't need to send it again. if the id has been changed, we need to update the client side. http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.39r2=1.336.2.40ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.39 php-src/ext/session/session.c:1.336.2.40 --- php-src/ext/session/session.c:1.336.2.39Sat May 8 02:01:11 2004 +++ php-src/ext/session/session.c Wed Jun 23 12:29:16 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.39 2004/05/08 06:01:11 pollita Exp $ */ +/* $Id: session.c,v 1.336.2.40 2004/06/23 16:29:16 sas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -930,8 +930,9 @@ { int module_number = PS(module_number); - if (PS(use_cookies)) { + if (PS(use_cookies) PS(send_cookie)) { php_session_send_cookie(TSRMLS_C); + PS(send_cookie) = 0; } /* if the SID constant exists, destroy it. */ @@ -1283,6 +1284,7 @@ PS(id) = PS(mod)-s_create_sid(PS(mod_data), NULL TSRMLS_CC); + PS(send_cookie) = 1; php_session_reset_id(TSRMLS_C); RETURN_TRUE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sniper Wed Feb 18 20:54:45 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: improve error message http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.31r2=1.336.2.32ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.31 php-src/ext/session/session.c:1.336.2.32 --- php-src/ext/session/session.c:1.336.2.31Mon Dec 8 05:01:11 2003 +++ php-src/ext/session/session.c Wed Feb 18 20:54:44 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.31 2003/12/08 10:01:11 abies Exp $ */ +/* $Id: session.c,v 1.336.2.32 2004/02/19 01:54:44 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -596,7 +596,7 @@ /* Open session handler first */ if (PS(mod)-s_open(PS(mod_data), PS(save_path), PS(session_name) TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, Failed to initialize storage module.); + php_error_docref(NULL TSRMLS_CC, E_ERROR, Failed to initialize storage module: %s (path: %s), PS(mod)-s_name, PS(save_path)); return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sniper Wed Feb 18 21:13:41 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: emalloc - safe_emalloc http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.336.2.32r2=1.336.2.33ty=u Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.32 php-src/ext/session/session.c:1.336.2.33 --- php-src/ext/session/session.c:1.336.2.32Wed Feb 18 20:54:44 2004 +++ php-src/ext/session/session.c Wed Feb 18 21:13:39 2004 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.32 2004/02/19 01:54:44 sniper Exp $ */ +/* $Id: session.c,v 1.336.2.33 2004/02/19 02:13:39 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1369,7 +1369,7 @@ if (argc = 0) RETURN_FALSE else - args = (zval ***)emalloc(argc * sizeof(zval **)); + args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0); if (zend_get_parameters_array_ex(argc, args) == FAILURE) { efree(args); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
abies Mon Dec 8 05:01:12 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: Fix build Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.30 php-src/ext/session/session.c:1.336.2.31 --- php-src/ext/session/session.c:1.336.2.30Sun Dec 7 11:53:30 2003 +++ php-src/ext/session/session.c Mon Dec 8 05:01:11 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.30 2003/12/07 16:53:30 sniper Exp $ */ +/* $Id: session.c,v 1.336.2.31 2003/12/08 10:01:11 abies Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -717,7 +717,6 @@ php_gmtime_r(when, tm); - n = sprintf(buf, %s, %d %s %d %02d:%02d:%02d GMT, /* SAFE */ n = sprintf(buf, %s, %02d %s %d %02d:%02d:%02d GMT, /* SAFE */ week_days[tm.tm_wday], tm.tm_mday, month_names[tm.tm_mon], tm.tm_year + 1900, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sas Thu Aug 28 13:34:31 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: format string fix Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.25 php-src/ext/session/session.c:1.336.2.26 --- php-src/ext/session/session.c:1.336.2.25Mon Aug 25 22:16:23 2003 +++ php-src/ext/session/session.c Thu Aug 28 13:34:30 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.25 2003/08/26 02:16:23 sniper Exp $ */ +/* $Id: session.c,v 1.336.2.26 2003/08/28 17:34:30 sas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -633,7 +633,7 @@ break; case HASH_KEY_IS_LONG: php_error_docref(NULL TSRMLS_CC, E_NOTICE, The session bug compatibility code will not - try to locate the global variable $%d due to its + try to locate the global variable $%lu due to its numeric nature., num_key); break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
andrey Thu Aug 28 16:26:33 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: \n at the end of the message is not needed Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.26 php-src/ext/session/session.c:1.336.2.27 --- php-src/ext/session/session.c:1.336.2.26Thu Aug 28 13:34:30 2003 +++ php-src/ext/session/session.c Thu Aug 28 16:26:32 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.26 2003/08/28 17:34:30 sas Exp $ */ +/* $Id: session.c,v 1.336.2.27 2003/08/28 20:26:32 andrey Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1055,7 +1055,7 @@ PS(mod)-s_gc(PS(mod_data), PS(gc_maxlifetime), nrdels TSRMLS_CC); #if 0 if (nrdels != -1) - php_error_docref(NULL TSRMLS_CC, E_NOTICE, purged %d expired session objects\n, nrdels); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, purged %d expired session objects, nrdels); #endif } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sniper Mon Aug 25 22:05:54 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: MFH: - Fixed crash bug when non-existing save/serializer handler is used Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.22 php-src/ext/session/session.c:1.336.2.23 --- php-src/ext/session/session.c:1.336.2.22Wed Aug 13 21:32:01 2003 +++ php-src/ext/session/session.c Mon Aug 25 22:05:53 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.22 2003/08/14 01:32:01 iliaa Exp $ */ +/* $Id: session.c,v 1.336.2.23 2003/08/26 02:05:53 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -91,17 +91,11 @@ return FAILURE; } PS(mod) = _php_find_ps_module(new_value TSRMLS_CC); -/* - * Following lines are commented out to prevent bogus error message at - * start up. i.e. Save handler modules are not initilzied before Session - * module. - */ -#if 0 - if(!PS(mod)) { + if (PG(modules_activated) !PS(mod)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, Cannot find save handler %s, new_value); } -#endif + return SUCCESS; } @@ -112,17 +106,11 @@ return FAILURE; } PS(serializer) = _php_find_ps_serializer(new_value TSRMLS_CC); -/* - * Following lines are commented out to prevent bogus error message at - * start up. i.e. Serializer modules are not initilzied before Session - * module. - */ -#if 0 - if(!PS(serializer)) { + if (PG(modules_activated) !PS(serializer)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, Cannot find serialization handler %s, new_value); } -#endif + return SUCCESS; } @@ -1651,26 +1639,28 @@ PHP_MINFO_FUNCTION(session) { ps_module **mod; + ps_serializer *ser; smart_str handlers = {0}; int i; for (i = 0, mod = ps_modules; i MAX_MODULES; i++, mod++) { if (*mod (*mod)-s_name) { - smart_str_appends(handlers, (*mod)-s_name); - smart_str_appendc(handlers, ' '); + smart_str_appends(save_handlers, (*mod)-s_name); + smart_str_appendc(save_handlers, ' '); } } - + php_info_print_table_start(); php_info_print_table_row(2, Session Support, enabled ); - if (handlers.c) { + if (save_handlers.c) { smart_str_0(handlers); php_info_print_table_row(2, Registered save handlers, handlers.c); smart_str_free(handlers); } else { php_info_print_table_row(2, Registered save handlers, none); } + php_info_print_table_end(); DISPLAY_INI_ENTRIES(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sniper Mon Aug 25 22:16:24 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: More crap from previous commits Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.24 php-src/ext/session/session.c:1.336.2.25 --- php-src/ext/session/session.c:1.336.2.24Mon Aug 25 22:15:19 2003 +++ php-src/ext/session/session.c Mon Aug 25 22:16:23 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.24 2003/08/26 02:15:19 sniper Exp $ */ +/* $Id: session.c,v 1.336.2.25 2003/08/26 02:16:23 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1639,7 +1639,6 @@ PHP_MINFO_FUNCTION(session) { ps_module **mod; - ps_serializer *ser; smart_str handlers = {0}; int i; @@ -1653,7 +1652,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Session Support, enabled ); - if (save_handlers.c) { + if (handlers.c) { smart_str_0(handlers); php_info_print_table_row(2, Registered save handlers, handlers.c); smart_str_free(handlers); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
At 04:10 22/07/2003, Sascha Schumann wrote: sas Mon Jul 21 21:10:31 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: Proper fix for #24592 The core issue is that undefined variables are refcounted (refcount != 0) while is_ref is still set to 0. I don't know whether this is a bug in the engine, but is it not the first time this irregularity has caused problems for the session extension. There's nothing irregular about it, the session extension should get used to it :) Zeev -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
On Tue, 22 Jul 2003, Zeev Suraski wrote: At 04:10 22/07/2003, Sascha Schumann wrote: sas Mon Jul 21 21:10:31 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: Proper fix for #24592 The core issue is that undefined variables are refcounted (refcount != 0) while is_ref is still set to 0. I don't know whether this is a bug in the engine, but is it not the first time this irregularity has caused problems for the session extension. There's nothing irregular about it, the session extension should get used to it :) If it is not irregular, the engine code should be able to deal with it correctly. Right now, it falls over itself quickly and dies ungracefully. (gdb) p *val $1 = (zval *) 0x816db84 (gdb) p **val $1 = {value = {lval = 0, dval = 0, str = {val = 0x0, len = 0}, ht = 0x0, obj = {ce = 0x0, properties = 0x0}}, type = 0 '\0', is_ref = 0 '\0', refcount = 6} Note the refcount value. When passing this zval to ZEND_SET_SYMBOL_WITH_LENGTH for the second time, the engine causes a segfault, because it tries to free memory it should not: (gdb) p *val $1 = (zval *) 0x816db84 (gdb) p **val $2 = {value = {lval = 0, dval = 0, str = {val = 0x0, len = 0}, ht = 0x0, obj = {ce = 0x0, properties = 0x0}}, type = 0 '\0', is_ref = 1 '\001', refcount = 6} 641 ZEND_SET_SYMBOL_WITH_LENGTH(ht, str, str_len, *val, (gdb) n [Tue Jul 22 11:04:30 2003] Script: 'f' --- php-src/ext/session/session.c(642) : Block 0x0816DB60 status: Beginning: Overrun (magic=0x, expected=0x7312F8DC) Program received signal SIGSEGV, Segmentation fault. 0x4010ca3c in memcpy () from /lib/libc.so.6 Testcase (without the IS_NULL check in migrate_global): ?php $foo = $bar = $a; @session_start(); $_SESSION['foo'] = $_SESSION['bar'] = $a; - Sascha -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
At 12:22 22/07/2003, Sascha Schumann wrote: If it is not irregular, the engine code should be able to deal with it correctly. Right now, it falls over itself quickly and dies ungracefully. Then ZEND_SET_SYMBOL_WITH_LENGTH should be fixed. I'm not sure who wrote it, but it wasn't Andi nor me. The engine works with it properly, more than that, it completely relies on this behavior. Zeev -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
On Tue, 22 Jul 2003, Zeev Suraski wrote: At 12:22 22/07/2003, Sascha Schumann wrote: If it is not irregular, the engine code should be able to deal with it correctly. Right now, it falls over itself quickly and dies ungracefully. Then ZEND_SET_SYMBOL_WITH_LENGTH should be fixed. I'm not sure who wrote it, but it wasn't Andi nor me. The engine works with it properly, more than that, it completely relies on this behavior. Where is this case (apparent optimization of undefined variables) documented? - Sascha -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
On Tue, 22 Jul 2003, Zeev Suraski wrote: At 12:22 22/07/2003, Sascha Schumann wrote: If it is not irregular, the engine code should be able to deal with it correctly. Right now, it falls over itself quickly and dies ungracefully. Then ZEND_SET_SYMBOL_WITH_LENGTH should be fixed. I'm not sure who wrote it, but it wasn't Andi nor me. The engine works with it properly, more than that, it completely relies on this behavior. Btw, here is the annotated source code. 1.33 (andi 03-Dec-99): #define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref) 1.18 (zeev 30-Jul-99): { 1.18 (zeev 30-Jul-99): zval **orig_var; 1.18 (zeev 30-Jul-99): 1.19 (zeev 30-Jul-99): if (zend_hash_find(symtable, (name), (name_length), (void **) orig_var)==SUCCESS 1.18 (zeev 30-Jul-99): PZVAL_IS_REF(*orig_var)) { 1.30 (zeev 01-Dec-99): (var)-refcount = (*orig_var)-refcount; 1.28 (andrei 18-Oct-99): (var)-is_ref = 1; 1.18 (zeev 30-Jul-99): 1.31 (zeev 01-Dec-99): if (_refcount) { 1.31 (zeev 01-Dec-99): (var)-refcount += _refcount-1; 1.31 (zeev 01-Dec-99): } 1.18 (zeev 30-Jul-99): zval_dtor(*orig_var); 1.30 (zeev 01-Dec-99): **orig_var = *(var); 1.44 (andi 24-Dec-99): FREE_ZVAL(var); 1.18 (zeev 30-Jul-99): } else { 1.32 (andi 02-Dec-99): (var)-is_ref = _is_ref; 1.30 (zeev 01-Dec-99): if (_refcount) { 1.30 (zeev 01-Dec-99): (var)-refcount = _refcount; 1.30 (zeev 01-Dec-99): } 1.30 (zeev 01-Dec-99): zend_hash_update(symtable, (name), (name_length), (var), sizeof(zval *), NULL); 1.18 (zeev 30-Jul-99): } 1.18 (zeev 30-Jul-99): } - Sascha -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
At 13:46 22/07/2003, Sascha Schumann wrote: On Tue, 22 Jul 2003, Zeev Suraski wrote: At 12:22 22/07/2003, Sascha Schumann wrote: If it is not irregular, the engine code should be able to deal with it correctly. Right now, it falls over itself quickly and dies ungracefully. Then ZEND_SET_SYMBOL_WITH_LENGTH should be fixed. I'm not sure who wrote it, but it wasn't Andi nor me. The engine works with it properly, more than that, it completely relies on this behavior. Where is this case (apparent optimization of undefined variables) documented? In the same place where the internals of your session module are documented. Zeev -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
At 13:49 22/07/2003, Sascha Schumann wrote: On Tue, 22 Jul 2003, Zeev Suraski wrote: At 12:22 22/07/2003, Sascha Schumann wrote: If it is not irregular, the engine code should be able to deal with it correctly. Right now, it falls over itself quickly and dies ungracefully. Then ZEND_SET_SYMBOL_WITH_LENGTH should be fixed. I'm not sure who wrote it, but it wasn't Andi nor me. The engine works with it properly, more than that, it completely relies on this behavior. Btw, here is the annotated source code. Ok, I guess I was the one who originally wrote it - it was a very long time ago. Can you give me a concrete example of when you think this macro doesn't behave properly? If it's correct, I'll try to fix it. Note that the last time you had problems with this (and other) macros these were actually bugs in the session module. Zeev -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
Can you give me a concrete example of when you think this macro doesn't behave properly? If it's correct, I'll try to fix it. Note that the last time you had problems with this (and other) macros these were actually bugs in the session module. That was another instance showing the inherent lack of abstraction in this particular API. What should be a black box is a test of familiarity with implementation details. ?php $foo = $bar = $a; @session_start(); $_SESSION['foo'] = $_SESSION['bar'] = $a; All four zvals are initialized using an undefined variable. During the shutdown phase, this occurs: zval **val; ht = Z_ARRVAL_P(PS(http_session_vars)); zend_hash_find(EG(symbol_table), foo, val); ZEND_SET_SYMBOL_WITH_LENGTH(ht, foo, *val, (*val)-refcount + 1 , 1); zend_hash_find(EG(symbol_table), bar, val); /* crash in FREE_ZVAL */ ZEND_SET_SYMBOL_WITH_LENGTH(ht, bar, *val, (*val)-refcount + 1 , 1); The contents of val at each stage can be seen here: http://news.php.net/article.php?group=php.cvsarticle=22706 - Sascha -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
At 14:56 22/07/2003, Sascha Schumann wrote: Can you give me a concrete example of when you think this macro doesn't behave properly? If it's correct, I'll try to fix it. Note that the last time you had problems with this (and other) macros these were actually bugs in the session module. That was another instance showing the inherent lack of abstraction in this particular API. Well, it was more of a misunderstanding on your part as to what you may and may not do with zvals which are managed by the engine. Apparently, this is the very same issue right now. What should be a black box is a test of familiarity with implementation details. My English parser stuck on that one... ?php $foo = $bar = $a; @session_start(); $_SESSION['foo'] = $_SESSION['bar'] = $a; All four zvals are initialized using an undefined variable. During the shutdown phase, this occurs: zval **val; ht = Z_ARRVAL_P(PS(http_session_vars)); zend_hash_find(EG(symbol_table), foo, val); ZEND_SET_SYMBOL_WITH_LENGTH(ht, foo, *val, (*val)-refcount + 1 , 1); zend_hash_find(EG(symbol_table), bar, val); /* crash in FREE_ZVAL */ ZEND_SET_SYMBOL_WITH_LENGTH(ht, bar, *val, (*val)-refcount + 1 , 1); From a quick glance it appears to be the very same bug I told you about a few months ago. Here's what I said back then: --- The source of the problem is this: 1. You fetch a value from the symbol table that has is_ref=0, and refcount1. EG(uninit..) is quite a common example of that, but it's definitely not unique - $foo = $bar = baz; will create such a beast too. 2. You tell zend_set_hash_symbol to make this value a reference. That in itself is a bug - you most probably want to attach only to one symbol, and not to other symbols who might be pointing to the same value. 3. Things really turn for the worse when EG(uninit..) becomes is_ref - that may cause all sorts of unexpected problems. What should be done is SEPARATE_ZVAL() on the symbol, prior to calling zend_set_hash_symbol(). As a matter of fact, chances are that we'd want SEPARATE_ZVAL() to be inside zend_set_hash_symbol() - I can't imagine a situation where we'd be in a position to enable/disable the is_ref bit arbitrarily without separating first. --- ZEND_SET_SYMBOL_WITH_LENGTH() was not designed to handle zvals which are already managed by the engine, but to introduce new zvals (you can see that it's being used by the various SET_VAR_*() macros, and was actually introduced to abstract them). It overwrites certain properties, such as the reference count and is_ref without taking into account the values that were in there before. For the record, there's nothing special about uninitialized_zval as far as these macros are concerned, even though doing the wrong thing on uninitialized_zval may have a more noticeable effect. A reference count higher than 1 with is_ref being 0 is perfectly normal, and like I told you last time around - can happen with things as simple as $a=$b=foo; Changing such a value to is_ref=1 (i.e., calling ZEND_SET_SYMBOL on that value, and providing is_ref=1) is almost definitely NOT what you want to do. The reason this macro argument is there to begin with is, again, because it was designed to introduce new values. The bottom line is that you should simply SEPARATE this zval (probably SEPARATE_IF_NOT_REF) before you send it back into the engine. Zeev -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_4_3) /ext/session session.c
sas Mon Jul 21 21:10:31 2003 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/sessionsession.c Log: Proper fix for #24592 The core issue is that undefined variables are refcounted (refcount != 0) while is_ref is still set to 0. I don't know whether this is a bug in the engine, but is it not the first time this irregularity has caused problems for the session extension. The irregularity confused ZEND_SET_SYMBOL_WITH_LENGTH which then did the wrong thing WRT null values. Fortunately, nulls can simply be ignored in this case, thus the old code is restored and a new condition is added. Index: php-src/ext/session/session.c diff -u php-src/ext/session/session.c:1.336.2.19 php-src/ext/session/session.c:1.336.2.20 --- php-src/ext/session/session.c:1.336.2.19Mon Jul 21 17:49:52 2003 +++ php-src/ext/session/session.c Mon Jul 21 21:10:30 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: session.c,v 1.336.2.19 2003/07/21 21:49:52 iliaa Exp $ */ +/* $Id: session.c,v 1.336.2.20 2003/07/22 01:10:30 sas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -628,19 +628,18 @@ uint str_len; ulong num_key; int n; - zval **val = NULL; + zval **val; int ret = 0; n = zend_hash_get_current_key_ex(ht, str, str_len, num_key, 0, pos); switch (n) { case HASH_KEY_IS_STRING: - if (zend_hash_find(EG(symbol_table), str, str_len, (void **) val) == SUCCESS val) { - if (!PZVAL_IS_REF(*val)) { - (*val)-is_ref = 1; - (*val)-refcount += 1; - zend_hash_update(ht, str, str_len, val, sizeof(zval *), NULL); - } + if (zend_hash_find(EG(symbol_table), str, str_len, + (void **) val) == SUCCESS +val Z_TYPE_PP(val) != IS_NULL) { + ZEND_SET_SYMBOL_WITH_LENGTH(ht, str, str_len, *val, + (*val)-refcount + 1 , 1); ret = 1; } break; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php