Skip to content

Commit 193ca72

Browse files
committed
address review comments
1 parent bc92c62 commit 193ca72

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

ext/session/session.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,11 +687,13 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */
687687
}
688688
return FAILURE;
689689
}
690-
/* Numeric session.name won't work at all */
690+
/* Numeric session.name won't work at all
691+
* See https://bugs.php.net/bug.php?id=35703
692+
(TL;DR: name is stored in HashTable so numeric string is converted to int key, but lookup looks for string key). */
691693
if (is_numeric_str_function(new_value, NULL, NULL)) {
692694
/* Do not output error when restoring ini options. */
693695
if (stage != ZEND_INI_STAGE_DEACTIVATE) {
694-
php_error_docref(NULL, err_type, "session.name \"%s\" cannot be numeric or empty", ZSTR_VAL(new_value));
696+
php_error_docref(NULL, err_type, "session.name \"%s\" cannot be numeric", ZSTR_VAL(new_value));
695697
}
696698
return FAILURE;
697699
}

ext/session/tests/session_name_variation1.phpt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ var_dump(session_name());
2121
var_dump(session_destroy());
2222
var_dump(session_name());
2323

24+
var_dump(session_name("15"));
25+
var_dump(session_start());
26+
var_dump(session_name());
27+
var_dump(session_destroy());
28+
var_dump(session_name());
29+
30+
var_dump(session_name("10.25"));
31+
var_dump(session_start());
32+
var_dump(session_name());
33+
var_dump(session_destroy());
34+
var_dump(session_name());
35+
2436
var_dump(session_name("\t"));
2537
var_dump(session_start());
2638
var_dump(session_name());
@@ -39,7 +51,21 @@ ob_end_flush();
3951
--EXPECTF--
4052
*** Testing session_name() : variation ***
4153

42-
Warning: session_name(): session.name "" cannot contain nul bytes in %s on line %d
54+
Warning: session_name(): session.name "" cannot contain NUL bytes in %s on line %d
55+
string(9) "PHPSESSID"
56+
bool(true)
57+
string(9) "PHPSESSID"
58+
bool(true)
59+
string(9) "PHPSESSID"
60+
61+
Warning: session_name(): session.name "15" cannot be numeric in %s on line %d
62+
string(9) "PHPSESSID"
63+
bool(true)
64+
string(9) "PHPSESSID"
65+
bool(true)
66+
string(9) "PHPSESSID"
67+
68+
Warning: session_name(): session.name "10.25" cannot be numeric in %s on line %d
4369
string(9) "PHPSESSID"
4470
bool(true)
4571
string(9) "PHPSESSID"

0 commit comments

Comments
 (0)