com php-src: Fixed bug #66827 Session raises E_NOTICE when session name variable is array: ext/session/sess ion.c ext/session/tests/bug66827.phpt

From: Date: Sat, 19 Jul 2014 00:52:31 +0000
Subject: com php-src: Fixed bug #66827 Session raises E_NOTICE when session name variable is array: ext/session/sess ion.c ext/session/tests/bug66827.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-79513@lists.php.net to get a copy of this message
Commit: e946de29d2f337f140780086b0ccefd13e2095ef Author: Yasuo Ohgaki <yohgaki@php.net> Sat, 19 Jul 2014 09:52:01 +0900 Parents: c5ccaf1d04fe20dc117b81764041c47efcb9b156 Branches: PHP-5.4 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e946de29d2f337f140780086b0ccefd13e2095ef Log: Fixed bug #66827 Session raises E_NOTICE when session name variable is array Bugs: https://bugs.php.net/66827 Changed paths: M ext/session/session.c A ext/session/tests/bug66827.phpt Diff: diff --git a/ext/session/session.c b/ext/session/session.c index 74a7f4a..7d145c3 100644 --- a/ext/session/session..c +++ b/ext/session/session.c @@ -1327,9 +1327,16 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) /* {{{ } /* }}} */ -#define PPID2SID \ - convert_to_string((*ppid)); \ - PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid)) +static void ppid2sid(zval **ppid TSRMLS_DC) { + if (Z_TYPE_PP(ppid) != IS_STRING) { + PS(id) = NULL; + PS(send_cookie) = 1; + } else { + convert_to_string((*ppid)); + PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid)); + PS(send_cookie) = 0; + } +} static void php_session_reset_id(TSRMLS_D) /* {{{ */ { @@ -1418,9 +1425,8 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ Z_TYPE_PP(data) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS ) { - PPID2SID; + ppid2sid(ppid TSRMLS_CC); PS(apply_trans_sid) = 0; - PS(send_cookie) = 0; PS(define_sid) = 0; } @@ -1429,8 +1435,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ Z_TYPE_PP(data) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS ) { - PPID2SID; - PS(send_cookie) = 0; + ppid2sid(ppid TSRMLS_CC); } if (!PS(use_only_cookies) && !PS(id) && @@ -1438,8 +1443,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ Z_TYPE_PP(data) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS ) { - PPID2SID; - PS(send_cookie) = 0; + ppid2sid(ppid TSRMLS_CC); } } diff --git a/ext/session/tests/bug66827.phpt b/ext/session/tests/bug66827.phpt new file mode 100644 index 0000000..4e1a4f7 --- /dev/null +++ b/ext/session/tests/bug66827.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #66827: Session raises E_NOTICE when session name variable is array. +--INI-- +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +$_COOKIE[session_name()] = array(); +session_start(); +echo 'OK'; +--EXPECTF-- +OK

« previous php.cvs (#79513) next »