Skip to content

Commit ef9a89f

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-19480: error_log php.ini cannot be unset when open_basedir is configured
2 parents e408bca + 9382260 commit ef9a89f

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

ext/standard/basic_functions.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,10 +1988,8 @@ PHP_FUNCTION(ini_set)
19881988
/* open basedir check */
19891989
if (PG(open_basedir)) {
19901990
if (
1991-
zend_string_equals_literal(varname, "error_log")
1992-
|| zend_string_equals_literal(varname, "java.class.path")
1991+
zend_string_equals_literal(varname, "java.class.path")
19931992
|| zend_string_equals_literal(varname, "java.home")
1994-
|| zend_string_equals_literal(varname, "mail.log")
19951993
|| zend_string_equals_literal(varname, "java.library.path")
19961994
|| zend_string_equals_literal(varname, "vpopmail.directory")
19971995
) {

main/main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,13 @@ static PHP_INI_MH(OnUpdateErrorLog)
697697
{
698698
/* Only do the open_basedir check at runtime */
699699
if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) &&
700-
new_value && zend_string_equals_literal(new_value, "syslog")) {
700+
new_value && !zend_string_equals_literal(new_value, "syslog") && ZSTR_LEN(new_value) > 0) {
701701
if (PG(open_basedir) && php_check_open_basedir(ZSTR_VAL(new_value))) {
702702
return FAILURE;
703703
}
704704
}
705-
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
705+
char **p = (char **) ZEND_INI_GET_ADDR();
706+
*p = new_value && ZSTR_LEN(new_value) > 0 ? ZSTR_VAL(new_value) : NULL;
706707
return SUCCESS;
707708
}
708709
/* }}} */
@@ -711,12 +712,13 @@ static PHP_INI_MH(OnUpdateErrorLog)
711712
static PHP_INI_MH(OnUpdateMailLog)
712713
{
713714
/* Only do the open_basedir check at runtime */
714-
if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && new_value) {
715+
if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && new_value && ZSTR_LEN(new_value) > 0) {
715716
if (PG(open_basedir) && php_check_open_basedir(ZSTR_VAL(new_value))) {
716717
return FAILURE;
717718
}
718719
}
719-
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
720+
char **p = (char **) ZEND_INI_GET_ADDR();
721+
*p = new_value && ZSTR_LEN(new_value) > 0 ? ZSTR_VAL(new_value) : NULL;
720722
return SUCCESS;
721723
}
722724
/* }}} */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Setting error_log to special values with open_basedir enabled
3+
--INI--
4+
open_basedir=foo
5+
error_log=
6+
--FILE--
7+
<?php
8+
var_dump(ini_set("error_log", "syslog"));
9+
var_dump(ini_set("error_log", ""));
10+
?>
11+
--EXPECT--
12+
string(0) ""
13+
string(6) "syslog"

0 commit comments

Comments
 (0)