Skip to content

Commit 5093327

Browse files
committed
address review comments
1 parent 1c604a5 commit 5093327

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
@@ -671,11 +671,13 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */
671671
}
672672
return FAILURE;
673673
}
674-
/* Numeric session.name won't work at all */
674+
/* Numeric session.name won't work at all
675+
* See https://bugs.php.net/bug.php?id=35703
676+
(TL;DR: name is stored in HashTable so numeric string is converted to int key, but lookup looks for string key). */
675677
if (is_numeric_str_function(new_value, NULL, NULL)) {
676678
/* Do not output error when restoring ini options. */
677679
if (stage != ZEND_INI_STAGE_DEACTIVATE) {
678-
php_error_docref(NULL, err_type, "session.name \"%s\" cannot be numeric or empty", ZSTR_VAL(new_value));
680+
php_error_docref(NULL, err_type, "session.name \"%s\" cannot be numeric", ZSTR_VAL(new_value));
679681
}
680682
return FAILURE;
681683
}

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)