Skip to content

Commit e946de2

Browse files
author
Yasuo Ohgaki
committed
Fixed bug #66827 Session raises E_NOTICE when session name variable is array
1 parent c5ccaf1 commit e946de2

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

ext/session/session.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,9 +1327,16 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) /* {{{
13271327
}
13281328
/* }}} */
13291329

1330-
#define PPID2SID \
1331-
convert_to_string((*ppid)); \
1332-
PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid))
1330+
static void ppid2sid(zval **ppid TSRMLS_DC) {
1331+
if (Z_TYPE_PP(ppid) != IS_STRING) {
1332+
PS(id) = NULL;
1333+
PS(send_cookie) = 1;
1334+
} else {
1335+
convert_to_string((*ppid));
1336+
PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid));
1337+
PS(send_cookie) = 0;
1338+
}
1339+
}
13331340

13341341
static void php_session_reset_id(TSRMLS_D) /* {{{ */
13351342
{
@@ -1418,9 +1425,8 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
14181425
Z_TYPE_PP(data) == IS_ARRAY &&
14191426
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS
14201427
) {
1421-
PPID2SID;
1428+
ppid2sid(ppid TSRMLS_CC);
14221429
PS(apply_trans_sid) = 0;
1423-
PS(send_cookie) = 0;
14241430
PS(define_sid) = 0;
14251431
}
14261432

@@ -1429,17 +1435,15 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
14291435
Z_TYPE_PP(data) == IS_ARRAY &&
14301436
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS
14311437
) {
1432-
PPID2SID;
1433-
PS(send_cookie) = 0;
1438+
ppid2sid(ppid TSRMLS_CC);
14341439
}
14351440

14361441
if (!PS(use_only_cookies) && !PS(id) &&
14371442
zend_hash_find(&EG(symbol_table), "_POST", sizeof("_POST"), (void **) &data) == SUCCESS &&
14381443
Z_TYPE_PP(data) == IS_ARRAY &&
14391444
zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS
14401445
) {
1441-
PPID2SID;
1442-
PS(send_cookie) = 0;
1446+
ppid2sid(ppid TSRMLS_CC);
14431447
}
14441448
}
14451449

ext/session/tests/bug66827.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #66827: Session raises E_NOTICE when session name variable is array.
3+
--INI--
4+
--SKIPIF--
5+
<?php include('skipif.inc'); ?>
6+
--FILE--
7+
<?php
8+
$_COOKIE[session_name()] = array();
9+
session_start();
10+
echo 'OK';
11+
--EXPECTF--
12+
OK

0 commit comments

Comments
 (0)