Skip to content

Commit 2a2cc2c

Browse files
committed
Fix type confusion with session SID constant
Closes GH-17548.
1 parent 0b3e637 commit 2a2cc2c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ PHP NEWS
4848
- PHPDBG:
4949
. Fix crashes in function registration + test. (nielsdos, Girgias)
5050

51+
- Session:
52+
. Fix type confusion with session SID constant. (nielsdos)
53+
5154
- SimpleXML:
5255
. Fixed bug GH-17409 (Assertion failure Zend/zend_hash.c:1730). (nielsdos)
5356

ext/session/session.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,15 +1479,15 @@ PHPAPI zend_result php_session_reset_id(void) /* {{{ */
14791479
smart_str_appends(&var, ZSTR_VAL(PS(id)));
14801480
smart_str_0(&var);
14811481
if (sid) {
1482-
zval_ptr_dtor_str(sid);
1482+
zval_ptr_dtor(sid);
14831483
ZVAL_STR(sid, smart_str_extract(&var));
14841484
} else {
14851485
REGISTER_STRINGL_CONSTANT("SID", ZSTR_VAL(var.s), ZSTR_LEN(var.s), 0);
14861486
smart_str_free(&var);
14871487
}
14881488
} else {
14891489
if (sid) {
1490-
zval_ptr_dtor_str(sid);
1490+
zval_ptr_dtor(sid);
14911491
ZVAL_EMPTY_STRING(sid);
14921492
} else {
14931493
REGISTER_STRINGL_CONSTANT("SID", "", 0, 0);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
SID constant type confusion
3+
--EXTENSIONS--
4+
session
5+
--SKIPIF--
6+
<?php include('skipif.inc'); ?>
7+
--INI--
8+
session.use_cookies=0
9+
session.use_only_cookies=1
10+
--FILE--
11+
<?php
12+
13+
define('SID', [0xdeadbeef]);
14+
session_start();
15+
var_dump(SID);
16+
17+
?>
18+
--EXPECT--
19+
string(0) ""

0 commit comments

Comments
 (0)