Skip to content

Commit 249a1e1

Browse files
committed
Fix RC assertion in fpm when php_admin_value setting fails
The value is temporarily duplicated. While the value is allocated persistently, it will be freed if the ini value can't be set. This is safe, given the value has not actually been stored. Exposed by phpGH-19619
1 parent 6194084 commit 249a1e1

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

sapi/fpm/fpm/fpm_php.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ static int fpm_php_zend_ini_alter_master(char *name, int name_length, char *new_
4141
ini_entry->modifiable = mode;
4242
}
4343
} else {
44+
/* The string wasn't installed and won't be shared, it's safe to drop. */
45+
GC_MAKE_PERSISTENT_LOCAL(duplicate);
4446
zend_string_release_ex(duplicate, 1);
4547
}
4648

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
RC violation on failed php_admin_value
3+
--SKIPIF--
4+
<?php include "skipif.inc"; ?>
5+
--FILE--
6+
<?php
7+
8+
require_once "tester.inc";
9+
10+
$cfg = <<<EOT
11+
[global]
12+
error_log = {{FILE:LOG}}
13+
[unconfined]
14+
listen = {{ADDR}}
15+
pm = dynamic
16+
pm.max_children = 5
17+
pm.start_servers = 1
18+
pm.min_spare_servers = 1
19+
pm.max_spare_servers = 3
20+
php_admin_value[precision]=-2
21+
EOT;
22+
23+
$code = <<<EOT
24+
<?php
25+
var_dump(ini_get('precision'));
26+
EOT;
27+
28+
$ini = <<<EOT
29+
precision=14
30+
EOT;
31+
32+
$tester = new FPM\Tester($cfg, $code);
33+
$tester->setUserIni($ini);
34+
$tester->start();
35+
$tester->expectLogStartNotices();
36+
$tester->request()->expectBody(['string(2) "14"']);
37+
$tester->terminate();
38+
$tester->close();
39+
40+
?>
41+
Done
42+
--EXPECT--
43+
Done
44+
--CLEAN--
45+
<?php
46+
require_once "tester.inc";
47+
FPM\Tester::clean();
48+
?>

0 commit comments

Comments
 (0)