Skip to content

Commit b777248

Browse files
committed
Re-fixed Bug #66481 (Calls to session_name() segfault when session.name is null)
1 parent 271053a commit b777248

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ PHP NEWS
55
- Core:
66
. Fixed bug #66286 (Incorrect object comparison with inheritance). (Nikita)
77

8+
- Session:
9+
. Fixed bug #66481 (Calls to session_name() segfault when session.name is
10+
null). (Laruence)
11+
812
?? ??? 2013, PHP 5.4.24
913

1014
- Core:

ext/session/session.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,10 @@ static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */
618618
static PHP_INI_MH(OnUpdateName) /* {{{ */
619619
{
620620
/* Numeric session.name won't work at all */
621-
if (PG(modules_activated) &&
622-
(!new_value_length || is_numeric_string(new_value, new_value_length, NULL, NULL, 0))) {
621+
if ((!new_value_length || is_numeric_string(new_value, new_value_length, NULL, NULL, 0))) {
623622
int err_type;
624623

625-
if (stage == ZEND_INI_STAGE_RUNTIME) {
624+
if (stage == ZEND_INI_STAGE_RUNTIME || stage == ZEND_INI_STAGE_ACTIVATE || stage == ZEND_INI_STAGE_STARTUP) {
626625
err_type = E_WARNING;
627626
} else {
628627
err_type = E_ERROR;

ext/session/tests/bug66481.phpt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #66481: Calls to session_name() segfault when session.name is null.
3+
--INI--
4+
session.name=
5+
--SKIPIF--
6+
<?php include('skipif.inc'); ?>
7+
--FILE--
8+
<?php
9+
10+
var_dump(session_name("foo"));
11+
var_dump(session_name("bar"));
12+
--EXPECTF--
13+
PHP Warning: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0
14+
15+
Warning: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0
16+
string(9) "PHPSESSID"
17+
string(3) "foo"

0 commit comments

Comments
 (0)