Skip to content

Commit 3ad2cc7

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: PS(mod_user_class_name) must not leak into next request
2 parents 0b2fe40 + 3071d85 commit 3ad2cc7

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

ext/session/session.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ static inline void php_rshutdown_session_globals(void) /* {{{ */
142142
PS(session_vars) = NULL;
143143
}
144144

145+
if (PS(mod_user_class_name)) {
146+
zend_string_release(PS(mod_user_class_name));
147+
PS(mod_user_class_name) = NULL;
148+
}
149+
145150
/* User save handlers may end up directly here by misuse, bugs in user script, etc. */
146151
/* Set session status to prevent error while restoring save handler INI value. */
147152
PS(session_status) = php_session_none;

ext/session/tests/gh9584.phpt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
--TEST--
2+
GH-9584: PS(mod_user_class_name) must not leak into next request
3+
--EXTENSIONS--
4+
session
5+
--SKIPIF--
6+
<?php include('skipif.inc'); ?>
7+
--FILE--
8+
<?php
9+
10+
class MySessionHandler extends SessionHandler implements SessionUpdateTimestampHandlerInterface
11+
{
12+
public function open($path, $sessname): bool {
13+
return true;
14+
}
15+
16+
public function close(): bool {
17+
return true;
18+
}
19+
20+
public function read($sessid): string|false {
21+
return 'foo|s:3:"foo";';
22+
}
23+
24+
public function write($sessid, $sessdata): bool {
25+
return false;
26+
}
27+
28+
public function destroy($sessid): bool {
29+
return true;
30+
}
31+
32+
public function gc($maxlifetime): int|false {
33+
return true;
34+
}
35+
36+
public function create_sid(): string {
37+
return sha1(random_bytes(32));
38+
}
39+
40+
public function validateId($sid): bool {
41+
return true;
42+
}
43+
44+
public function updateTimestamp($sessid, $sessdata): bool {
45+
return false;
46+
}
47+
}
48+
49+
$handler = new MySessionHandler();
50+
session_set_save_handler($handler);
51+
52+
?>
53+
===DONE===
54+
--EXPECT--
55+
===DONE===

0 commit comments

Comments
 (0)