Skip to content

Commit f95433a

Browse files
committed
Fix GH-20727: User code can run after module request shutdown via the output layer
If user code runs after modules executed RSHUTDOWN, it can be dangerous because user code can rely on module globals that have already been invalidated. We should not run user code after RSHUTDOWN. This is shown by the test by using putenv(). The original report demonstrated a silent failure via mbstring. There are more test cases possible but this is by far the simplest. An alternative solution would be to try to separate the user code running via php_header() from the output layer shutdown, to make sure user code runs earlier. However, that becomes an ugly complex solution. This PR's solution keeps things simple but this can be a BC break if extensions produce output in their RSHUTDOWN handler (However, that may have been unsafe in the first place).
1 parent db65503 commit f95433a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-20727 (User code can run after module request shutdown via the output layer)
3+
--FILE--
4+
<?php
5+
putenv('foo=baz');
6+
header_register_callback(function(){
7+
var_dump(putenv('foo=bar'));
8+
});
9+
?>
10+
--EXPECT--
11+
bool(true)

0 commit comments

Comments
 (0)