Skip to content

Commit 5d010c6

Browse files
Girgiasjorgsowa
authored andcommitted
address review comments
1 parent c486d3d commit 5d010c6

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

ext/session/session.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,13 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */
704704
}
705705
return FAILURE;
706706
}
707-
/* Numeric session.name won't work at all */
707+
/* Numeric session.name won't work at all
708+
* See https://bugs.php.net/bug.php?id=35703
709+
(TL;DR: name is stored in HashTable so numeric string is converted to int key, but lookup looks for string key). */
708710
if (is_numeric_str_function(new_value, NULL, NULL)) {
709711
/* Do not output error when restoring ini options. */
710712
if (stage != ZEND_INI_STAGE_DEACTIVATE) {
711-
php_error_docref(NULL, err_type, "session.name \"%s\" cannot be numeric or empty", ZSTR_VAL(new_value));
713+
php_error_docref(NULL, err_type, "session.name \"%s\" cannot be numeric", ZSTR_VAL(new_value));
712714
}
713715
return FAILURE;
714716
}

ext/session/tests/session_name_variation1.phpt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ ob_start();
1515

1616
echo "*** Testing session_name() : variation ***\n";
1717

18+
var_dump(session_name("\0"));
19+
var_dump(session_start());
20+
var_dump(session_name());
21+
var_dump(session_destroy());
22+
var_dump(session_name());
23+
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+
1836
var_dump(session_name("\t"));
1937
var_dump(session_start());
2038
var_dump(session_name());
@@ -33,7 +51,21 @@ ob_end_flush();
3351
--EXPECTF--
3452
*** Testing session_name() : variation ***
3553

36-
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
3769
string(9) "PHPSESSID"
3870

3971
Warning: session_start(): session.name cannot contain any of the following '=,;.[ \t\r\n\013\014' in %s on line %d

0 commit comments

Comments
 (0)